Submitted On 30-AUG-2002
PoleshuckR
We have a similar problem. We have a large server application
that frequently leaves more than a gigabyte of memory
reported by freeMemory(); We would like to return this
memory to the operating system.
Submitted On 26-MAY-2003
desd1012
U S E L O C K E D M E M O R Y
ALLOW FOR NON-SWAPABLE MEMORY jvm switches, like min
locked, max locked, lock eden, etc...
Trying running a large program JVM that does not swap, (lock
the memory with tools like memory+): it is very fast.
It does not swap all in from disk to perform a stupid GC of
30 seconds!! I swear, I constantly see 10, 20 or even 30
seconds FullGC on my eclipse IDE.
The jvm and the OS, in this way of working together are
wasting CPU and dsisk I/O.
THIS IS URGENT: no decent server can be written in java
right now, it swaps all the time, even with plenty or
physical ram.
Submitted On 06-OCT-2003
uncleHohoho
I have exactly the same problem. I have a client app that is
only using 8MB of heap, but the heap size stay at 40MB. The
heap size soars during an expensive load operation and never
returns to it's original state. I can't believe this was only
reported during. Will this be fixed in 1.4.2_02 or 1.5??
Submitted On 11-MAR-2004
uzay
I have the same problem. Even though I have used
-XX:MaxHeapFreeRatio=20 -XX:MinHeapFreeRatio=10,
they do not seem to affect the free memory ratio. JVM
still keeps around 40% free.
Since my problem occurs in an applet, unlike the first
comment, I can not stop and restart the applet.
1. The ratio should be forced strictly. Why the -XX
option would exist if it is not forced?
2. I certainly believe the 70% free ratio for hotspot or
client JVM is too high. 20% is more reasonable. When
the server JVM is selected, the ratio can be defaulted to
a higher value.
3. When the activity of the JVM is low for a long period
of time, e.g. for 3-4 mins, and the free mem ratio is
70%, still the heap size should be dropped and the
free mem should be lowered to 20-30% level.
4. Why the default free min heap ratio is 40%? This
might be reasonable when your memory allocation is
1-2MBs but it does not make sense when the memory
allocation is 100s or 10s of MBs.
Submitted On 23-DEC-2004
pifpafpuf
In addition to using -XX:MaxHeapFreeRatio=20 -XX:MinHeapFreeRatio=10 I found that it
seems to be necessary to call Runtime.gc()
explicitely to convince it to give back memory
to the OS. And even more than once. Then
it at least goes in the requested direction. Here
is my run() implementation for a Runnable I call
ConvinceGC. The variables count and out
are initialized in the constructor, rt is the Runtime.
public void run() {
while( count-->0 ) {
rt.gc();
if( out!=null ) {
long free = rt.freeMemory();
long total = rt.totalMemory();
String pcent
= new Double((double)free/(double)total*100.0).toString();
pcent = pcent.substring(0,pcent.indexOf(".")+2);
out.println("ConvinceGC: allocated="+total+
", used="+(total-free)+
", free="+free+" ("+pcent+")");
}
if( Thread.interrupted() ) break;
try {
Thread.sleep(1000);
} catch( InterruptedException e ) {
// Assume this asks us to quit working
break;
}
}
if( out!=null ) out.println("ConvinceGC exiting");
}
It would be great to have an API to GC to tell it
"Really, dear GC, now is definitively the time to
give back memory to the OS. Please, please...".
Submitted On 13-JUN-2005
schlm3
-XX:MinHeapFreeRatio and -XX:MaxHeapFreeRatio defaults should really be lower. The Default of 40 respectively 70% may make sense for small Applications but larger ones operate much faster on most systems with lower Values, because the system needs less I/O (swapping).
Maybe consider allowing absolute values (e.g. 20m).
Submitted On 30-AUG-2006
davehornig
As long as this RFE is still open, I'll add my 2 cents:
(1) I spent a lot of time trying to figure out why Tomcat wasn't passing the HeapFreeRatio parameters to Java, before finally realizing that Java was probably getting them but just not able to use them. It would be good to put the appropriate caveats into http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html, saying they can be set but we shouldn't expect them to be obeyed all of the time.
(2) The workaround given in this RFE seems to imply that the cost of virtual memory is just disk space (?). The more serious issue is disk I/O. I won't pretend to understand the details of Java's full GC, but full GCs by their nature tend to page in much of the address space, and we have seen serious swapping problems when virtual memory is only 20% larger than physical memory.
In sum this is a serious practical issue for those of us who use Java in a server environment. If it isn't possible to fix (and the difficulties pointed out in this RFE's Evaluation are well-taken) then it should be carefully documented in the "Tuning Garbage Collection" guide.
Submitted On 20-JUN-2008
Luzius313
This issue is partially responsible for Java's reputation as a memory hog.
I am the CTO of a company whose main product is a Java desktop application with
tens of thousands of installations running daily. One of the major problems our
users report in feedback and in satisfaction surveys is memory consumption. They
open the task manager (most of them use Windows) and see our application using
200MB of RAM even though most of the time it actually uses only around 40MB (the
200MB are only needed temporarily for operations like resizing an image). Fixing
this bug could resolve this issue and improve consumer perception of Java a lot!
(Even if it doesn't make a big difference technically.) For our purposes, making
the windows task manager showing the 40MB we actually use within the JVM instead
of the 200MB the JVM keeps allocated because we used that much temporarily would
already fix the problem.
Submitted On 20-JUN-2008
ioj
Does this bug really apply to all operating systems equally?
Submitted On 20-JUN-2008
Luzius313
It turns out I was wrong and Java does sometimes return memory to the OS, even on Windows. Example:
http://pastebin.org/44909
So I guess it is really a question of optimizing the Java program itself, accompanied by a tuning of the MaxHeapFreeRatio parameter.
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|