-
Notifications
You must be signed in to change notification settings - Fork 556
Open
Labels
Area: App RuntimeIssues in `libmonodroid.so`.Issues in `libmonodroid.so`.Area: PerformanceIssues with performance.Issues with performance.enhancementProposed change to current functionality.Proposed change to current functionality.
Milestone
Description
Currently, the Java Callable Wrappers use an ArrayList
and methods to help mirror the object graph from the Mono GC to the Android GC:
/* partial */ class Example {
ArrayList<Object> managedReferences = new ArrayList<Object>();
public void monodroidAddReference (Object o) {
managedReferences.add (o);
}
public void monodroidClearReferences () {
managedReferences.clear ();
}
}
monodroidAddReference()
and monodroidClearReferences()
are called via JNI within osbridge.cc
:
An idea occurred to me: what if instead of invoking monodroidAddReference()
/etc., we instead used a field?
/* partial */ class Example {
Object []managedReferences;
}
This would reduce Java-side memory allocations (no ArrayList<Object>
), and would alter the number of JNI invocations needed, from num_xrefs
JNIEnv::CallVoidMethod()
invocations to num_xrefs
calls to JNIEnv::SetObjectArrayElement()
+ 1 JNIEnv::SetObjectField()
. (Presumably JNIEnv::SetObjectArrayElement()
will be faster than JNIEnv::CallVoidMethod()
.)
Metadata
Metadata
Assignees
Labels
Area: App RuntimeIssues in `libmonodroid.so`.Issues in `libmonodroid.so`.Area: PerformanceIssues with performance.Issues with performance.enhancementProposed change to current functionality.Proposed change to current functionality.