views:

54

answers:

2

Hi Folks,

I have a java app that has a max heap of 1024M,it has perm gen space of 256M. Does it guarantee that this app will never use more than 1280M (1024+256) ?

Does the stack memory also come from the heap size above or is it extra memory consumption?

What if the java app uses native code that consumes memory then where does this memory come from? heap/perm gen / more ram?

I am interested to know how java uses memory. please comment. Any links that can provide a clear picture are also welcome

thankyou

+1  A: 

From your question I see how confused you are about memory management in Java.

Please go through this white paper for better understanding. http://java.sun.com/j2se/reference/whitepapers/memorymanagement_whitepaper.pdf

YoK
+2  A: 

An executing Java app uses more memory than the main heap and permgen space. For example:

  • There is the memory that holds the executable code of the java program and any shared libraries that are dynamically linked by the executable.
  • There is the memory used to represent out-of-heap data structures, buffers, etc that are created by the java executable, by its native libraries or by the application's native libraries.
  • There is the memory used to represent Java thread stacks.
  • And there's probably more.

There is no recommended way to predict the total memory usage of a Java application. Even measuring it is tricky, especially when you consider that some of that memory may be shared with other JVMs or even other non-Java applications.

Stephen C