Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Memory management while implementing JNI interfaces.

999713Mar 28 2013 — edited Mar 28 2013
The assumption here is that java code calls a C function from a
shared library in Linux.

How should memory management be done in the native code called
from Java using a JNI interface?

What role does the Garbage Collector play in handling memory that
was allocated in the native C code?

If I allocate memory using malloc() in the C program, should I
explicitly free it? Will the GC take care of it?

Does anyone have an idea of how memory management be done while
implementing a JNI interface?

Thanks,
Nisahnt
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 25 2013
Added on Mar 28 2013
3 comments
3,471 views