Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

does gc return memory to operation system?

 
w jc
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm novice, if my question is too simple or strange to answer, forgive me.

I engaged a project developed by swing, and configure -Xms32m and -Xmx64m as project maximum memeory for jvm. when i open some frames contains
some Jpanel contiunally, the window's taskmanager show memory occupied by javaw rise again and again.
my question is: since jvm start with -Xms32m, it should have has enough memory for some frames, why malloc from operation system?
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, if you are using Windows Task Manager to look at memory usage, be sure to use the "VM Size" column. The "Mem Usage" column can be confusing, as it relates to physical memory.

Second, even when looking at VM Size column, this is telling you about all memory used by the JVM. The Java heap is only one part of that memory. There is additional memory for the JVM's implementation code, loaded Java classes and a variety of other non-heap resources.

In your particular application, I would be surprised if Java was actually increasing the heap size from the initial 32 Mbytes. If it is, then I suspect that either your application is more complicated than you suggest or you have a leak.

To find out whether your application really is increasing the heap size, try setting the maximum heap to 32 Mbytes as well. If the application runs OK and the VM Size is similar to before, then any observed memory consumption increase is due to things other than Java heap.
 
w jc
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,Peter Chase
thanks for your reply.

the phenomenon i talked last article is based on IBM JDK1.3, then i
replace it with SUN JDK 1.4, the strange phenomenon disappeared.

Suppose IBM modified System.gc()? any way to solve this question which
my project must run with IBM JDK1.3?
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.gc() isn't guaranteed to do anything, so it might well be that the IBM implementation differs significantly from Sun's.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic