Thanks for this information, it was very useful.

Rol.

Nadav Har'El wrote:
On Tue, Jan 16, 2007, Rollo du Pre wrote about "Re: Websphere and Dark Matter":
I was hoping it would, yes. Does websphere not release memory back to the OS when it not longer needs it? I'm concerned that if the memory spiked for some reason (indexing a large document) then that would hamper the rest of the OS because it'd hold on to far more memory than is needed.

This is a well known, may I say infamous, Java issue. Java could, in theory,
easily shrink its heap as soon as it needs less memory, because in Java's GC
model, memory can be moved around so fragmentation is not a problem. But
unfortunately, the JVM's heap rarely does shrink by default: once the JVM's
heap grows, it rarely ever shrinks back.

It turns out that in Sun's JVM (at least in the 1.4 version which I tried),
you can actually control and improve the shrinking behavior. There's an option
"-XX:MaxHeapFreeRatio=" (see [1]) which basically means how much of the Heap
should be free before it is physically shrunk. Another option
"-XX:MinHeapFreeRatio=" specifies how much of the heap to leave free after
the shrinking.

The default values are 70 and 40 respectively, which means that the JVM only
shrinks its memory use after 70% (!!!) of the heap is free, and it only shrinks
to the point that 40% of the heap is still free. A few numbers to put this
waste into perspective: If your JVM's heap grew to 300 MB, and now only
requires 100 MB, it will NOT shrink (because only 66% is free). If later
you need just 90 MB, the heap will finally shrink, but only to 150 MB (so
that 40% still remains free).

One important thing you should note if you decide to lower these percentages,
is that much of the JVM's excellent GC performance relies on its "generation"
approach and the availability of a lot of free heap (so that by the time the
heap is exausted, most of the new stuff in it is already garbage). So to
keep performance - not just minimal memory use - you might want to tune other
GC parameters as well. A good combination I once used is this:

        -XX:NewRatio=2 -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=30

But your milage may vary.

[1] http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp


--
Rollo du Pre
Software Architect
[EMAIL PROTECTED]

www.i-nexus.com

NOTICE: The information contained in this e-mail, including
any attachments, is confidential. If you have received this
in error you should not disclose, copy, circulate or in any
way use the information contained herein. This e-mail may
be legally privileged and unauthorised use may be unlawful.
If you have received this e-mail in error, please telephone
us on +44 (0)870 011 0622 immediately so we can arrange for
its return. Thank you.

In addition, the opinions expressed in this e-mail are those
of the employee and for the intended recipient(s) only. They
do not necessarily represent the opinions of i-solutions
Global Ltd.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to