Saturday, January 25, 2014
JNI layer newstringutf memory problems. .
In JNI layer () function is used newstringutf, created a jstring returned to the JAVA layer, JNI layer does not perform deletelocalref functions. .
That will not cause memory problems. .
ReferenceTable overflow (max = 1024)
currently appearsProblems. .
Reply:
Will be a memory leak ah, so prompt ReferenceTable overflow (max = 1024)
Reply:
Which returns JString how yet. .
Reply:
Return to call a function in Java layer jni layer, designed to free up some resources like ah.
Reply:
Cited by way of JNI processing, create a JString returned to JAVA layer JNI C function, but as a reference to the object placed outside.
Then write a C function, the release operation performed.
Like this.
jchar * cc = 0;
jstring getString () {
cc = "hello, guy";
return newStringUtf (cc);
}
void release () {
cc = 0;
}
Reply:
In other words,
That is, if there is no function in this release, it will cause a memory reference table overflow, but GC JAVA layer will not automatically delete the memory?
Reply:
JAVA GC is not so go and release,
Moreover, you use native, the data should be placed jvm jni layer of native method stack in.
Reply:
jclass ref = (env) -> FindClass ("java / lang / String");
env-> DeleteLocalRef (ref);
The deleted objects referenced in the JNI layer.
Reply:
Return to the java object in the jvm will be managed, so do not worry it will not be recovered in jni, only the objects in the C-terminal end of the need to be free fall, generating even in java, but did not use in the C-terminal object returned, there will be a memory leak, therefore, need free, returned by the return to java, and C is generated object does not need to manually free.
Reply:
JVM cleanup is achieved it, it will not be for some time to clean up, if not cleaned, it will not cause JNI into
ReferenceTable overflow (max = 1024) overflow.
Reply:
jvm cleanup is automatic garbage collection, and clean java object is the same, as when the clean-up, the jvm themselves to be responsible, you can not manage, but will not cause an overflow, unless the object has been cited.
If you wish to immediately recall, you can write yourself a native of the free bar and free incoming object out.
But not recommended.
Reply:
The landlord has no right solution?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment