title: How to calculate the max memory that can be used by a java app
body: <p>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) ?</p>
  
  <p>Does the stack memory also come from the heap size above or  is it extra memory consumption?</p>
  
  <p>What if the java app uses native code that consumes memory then where does this memory come from? heap/perm gen / more ram?</p>
  
  <p>I am interested to know how java uses memory.
  please comment.
  Any links that can provide a clear picture are also welcome</p>
  
  <p>thankyou</p>