Java heap vs OS memory

B

Bob Sullivan

Does anyone know why the Windows task manager reports so much more
memory usage for javaw.exe than the size of the java heap reported by
Runtime.getRuntime().totalMemory()? For example we have an app
running with a heap of 80MB while the task manager shows the memory of
javaw.exe at 111MB. That's a 31MB difference. What might account for
the additional memory?
 
R

Roedy Green

For example we have an app
running with a heap of 80MB while the task manager shows the memory of
javaw.exe at 111MB. That's a 31MB difference. What might account for
the additional memory?

Just guessing here. You really need to talk to someone who worked on
the Java.exe jvm.

1. Perhaps the stack frames are not considered part of the heap, and a
fair chunk of virtual RAM is reserved for stack frames.

2. There is a fair chunk of native code. This unlikely in considered
part of the heap even if dynamically loaded late in the game.

3. It is possible the class files are loaded in to a different area of
memory from the heap.

4. It is possible the interned Strings are not considered part of the
heap.

What you really want to know his how much REAL memory is used for
various purposes, not just how address space is reserved in virtual
memory. If you look only at virtual RAM, Java can look much more
profligate than it really is.
 
X

Xavier Tarrago

Very strange! I noticed that you can reduce dramatically the size reported
by taskmanager by iconifying and de-iconifying the application. Try it. My
eclipse workbench used to crash with a memory error. I thought that there
were a memory leak because taskmanager reported a regularly growing memory
size. And eclipse crashed at ~100 Mbytes. I increased max heap size, and now
all works fine. But the size grows up to 200 Mbytes. Iconifying eclipse make
this size to drop to 8 Mbytes! I do not understand, but it works, so ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,999
Messages
2,570,247
Members
46,844
Latest member
JudyGvh32

Latest Threads

Top