tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: tomcat memory usage
Date Wed, 27 Jan 2010 15:56:24 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hüsnü,

On 1/27/2010 2:06 AM, Hüsnü Þentürk wrote:
> As far as I know, heap memory is used by objects. On the other hand,
> our application has static variables and references to the objects
> residing in heap area. Does it mean, static variables and references
> of our application are stored outside of reserved 512MB area? Or, the
> memory outside of 512MB reserved heap area used only by Java itself?

No. All Java objects and their associated data are stored within the
heap. Unless you are writing JNI code, then everything you are effecting
is happening in the heap. Static variables and references (which are the
same thing, depending on how you see things) are not special in any way
when it comes to memory use.

It's the JVM itself which is allocating memory outside that heap.
Memory, for instance, to help manage the heap itself. And all the
threads you've got running. And the garbage collector.

Basically:

total memory = heap memory + non-heap memory

Using JVM options, you can really only effect the heap memory size, the
PermGen space, and the size of thread stacks. Basically, there is going
to be some extra memory needed for non-heap stuff. Especially on
Windows, I've seen reports of non-heap memory piling up quite a bit.

Something else to note: Windows' Task Manager is a terrible tool for
memory profiling, even without regard to Java's GC/heap issues. WTM just
shows you a single number for "memory" and doesn't explain anything.
Many DLLs loaded into a process's memory space are, in fact, shared with
many other processes. For instance, win32.dll (or whatever it's called
these days) gets mapped-into practically every process that runs under
Microsoft Windows. The memory used by that DLL is proably counted
against that process in WTM, when a lot of it is really being shared by
all processes. Yes, there is a lot of process-private (and
thread-private) data, but the fact that WTM shows you only a single
number for "memory" means that you're not getting the whole story.

Hmm... I'm looking at SysInternals (yes, they've been bought but I pine
for Mark Russinovich's freedom) Process Explorer and it looks like WTM
might be giving you the "private working set" which is essentially the
memory that only that process is using. For instance, WTM reports that
firefox.exe right now is using ~575MiB. (The column explicitly says
"private working set" if I expand it enough).

Process Explorer reports:
Virtual Memory
  Private Bytes:      ~ 762MiB
  Peak Private Bytes: ~ 880MiB
  Virtual Size:       ~1108MiB

Physical Memory:
  Working Set:        ~ 599MiB
    WS Private:       ~ 575MiB
    WS Shareable:     ~  23MiB
    WS Shared:        ~  10MiB
  Peak Working Set:   ~ 835MiB

WTM has gotten a lot better since the last time I checked: you can
choose which columns to view and it has an array of memory-related data
you can display.

So, maybe WTM is giving you a decent measure of what memory is actually
being used by that process, specifically.

Anyhow, you have to realize that virtual machines are complex beasts and
that there's more going on that your own code running inside that VM.

Other than the surprising realization that a 512MiB heap yields a 600MiB
process, is there a particular problem with the difference, here?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAktgYigACgkQ9CaO5/Lv0PAE4gCfe02Wp9q7LonyBl4a4b0+OyOP
AFcAnjxPJ0djagrgBSWAlrETrsHhEkWJ
=M6aj
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message