0

I run a Java program on an Ubuntu server. I allocate max 2560 MB to Java heap and max 128 MB to Java PermGen using the command-line parameters. After an hour or so I go take a look at memory usage. From inside the Java app it looks like it still has allocated about 2500 MB to heap but in ubuntu it looks like the JVM is using 3500 MB!

How can this be? Surely the JVM shouldn't use more than heap + permgen + a little more for stack and some other small stuff.

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614

1 Answers1

0

If it is a multithreaded application, each thread will have its own stack. If you you provide parameter -xss for stack memory of thread then it is quite possible.

Lokesh
  • 7,810
  • 6
  • 48
  • 78
  • 1
    You'd need at least a few hundred threads to tie up that much stack space. – cHao May 27 '13 at 16:44
  • @cHao which can happen, if he has a few hundred clients on server side and for each client allocate: a reader + a writer + a worker thread –  May 27 '13 at 16:45
  • @matheszabi: Eh. One would have to be *trying* to waste threads in order to come up with a design like that. But i guess. – cHao May 27 '13 at 16:50