JNI implications on HotSpot
Tony Printezis
Antonios.Printezis at sun.com
Mon Oct 6 09:22:57 PDT 2008
Hi,
Michael Finocchiaro wrote:
> So, is there a white paper that describes in detail the differences
> between memory management for Java objects and for native objects via
> JNI code?
I don't know if there is one. But the difference is very simple. Objects
allocated from Java and native malloc'ed objects are totally different,
reside on different memory areas, and are managed by different
mechanisms. Java objects are managed by the GC, malloc'ed objects need
to be explicitly freed (like any other malloc'ed object).
> How does the garbage collection work for the JNI objects
To make sure we're clear: by "JNI objects" you mean "objects that have
been malloc'ed from a JNI method", right? The GC doesn't know anything
about them and, as a result, it doesn't manage them at all. It's up to
the programmer to manage those.
> and thus how does one tune a JVM when the majority of code is
> (!groan!) C++ loaded into an application server via a war and
> initiated via JNI?
Carefully? :-)
> There must be some best practices out there, or at least some
> description of the differences between Java object memory management
> and native object memory management. At least I hope there
> is...otherwise I suppose I'll be treading water...
Maybe the GC list is not the best place for JNI best practices?
Tony
> Michael Finocchiaro
> michael.finocchiaro at gmail.com <mailto:michael.finocchiaro at gmail.com>
> Mobile Telephone: +33 6 85 46 07 62
> MSN: le_fino at hotmail.com <mailto:le_fino at hotmail.com>
> Blog: http://mfinocchiaro.wordpress.com
> Bookmarks: http://del.icio.us/michael.finocchiaro
>
>
> On Mon, Oct 6, 2008 at 4:43 PM, Tony Printezis
> <Antonios.Printezis at sun.com <mailto:Antonios.Printezis at sun.com>> wrote:
>
> Hi.
>
>
> Michael Finocchiaro wrote:
>
> I was wondering if there were any thoughts, or better yet,
> white papers, on the performance implications of JNI code on
> HotSpot performance and configuration. The malloc()s in the
> native JNI code are allocated on the Eden heap with other Java
> objects and subject to the same rules?
>
> Absolutely not. The Java heap is mmaped and we use custom memory
> management (GC!) and allocators for it; malloc uses a different
> space for allocations.
>
> Tony
>
> Or not? Any boundary conditions to beware of? Google was not
> particularly helpful so I am coming to the experts :)
> Cheers,
> Fino
>
>
>
> Michael Finocchiaro
> michael.finocchiaro at gmail.com
> <mailto:michael.finocchiaro at gmail.com>
> <mailto:michael.finocchiaro at gmail.com
> <mailto:michael.finocchiaro at gmail.com>>
>
> Mobile Telephone: +33 6 85 46 07 62
> MSN: le_fino at hotmail.com <mailto:le_fino at hotmail.com>
> <mailto:le_fino at hotmail.com <mailto:le_fino at hotmail.com>>
>
> Blog: http://mfinocchiaro.wordpress.com
> Bookmarks: http://del.icio.us/michael.finocchiaro
> ------------------------------------------------------------------------
>
> _______________________________________________
> hotspot-gc-use mailing list
>
> hotspot-gc-use at openjdk.java.net
> <mailto:hotspot-gc-use at openjdk.java.net>
> http://mail.openjdk.java.net/mailman/listinfo/hotspot-gc-use
>
>
>
> --
> ----------------------------------------------------------------------
> | Tony Printezis, Staff Engineer | Sun Microsystems Inc. |
> | | MS BUR02-311 |
> | e-mail: tony.printezis at sun.com <mailto:tony.printezis at sun.com>
> | 35 Network Drive |
> | office: +1 781 442 0998 (x20998) | Burlington, MA01803-0902, USA |
> ----------------------------------------------------------------------
> e-mail client: Thunderbird (Solaris)
>
>
>
--
----------------------------------------------------------------------
| Tony Printezis, Staff Engineer | Sun Microsystems Inc. |
| | MS BUR02-311 |
| e-mail: tony.printezis at sun.com | 35 Network Drive |
| office: +1 781 442 0998 (x20998) | Burlington, MA01803-0902, USA |
----------------------------------------------------------------------
e-mail client: Thunderbird (Solaris)
More information about the hotspot-gc-use
mailing list