title: Java Out of Memory Error(Native memory), the process size limit was hit(32-bit linux)
body: <p>I am testing the performence of a web application, and have got "Out of Memory Error"(native memory). </p>
  
  <p>I have test several times, and every time it "failed to allocate 83886088 bytes for Chunk::new" and died.</p>
  
  <p>I print the memory size every minute, and found that the VmSize was 2924700 kB before the process died.</p>
  
  <p>I think that the process size limit was hit. I change -Xmx2000m to -Xmx1900m and it's OK now.</p>
  
  <p>Some questions:</p>
  
  <p>1.How to comfirm that the process size limit was hit. It's not exactly 3G memory.</p>
  
  <p>2.Why JVM allocate 83886088 bytes memory every time? From the exception stack, it seems that it's related to GC things.</p>
  
  <p>3.How many memory should be reserved for JVM besides heap memory(-Xmx) and non-heap memory(-XX:MaxPermSize)? And how to know how many it's using now?</p>
  
  <p>Thanks and sorry for my poor English. </p>
  
  <p>Linux 2.6.16.60-0.83.2-bigsmp
  JRE 6.0_25-b06
  Tomcat 7.0.37</p>
  
  <pre><code>jvm options: -Xms2000m -Xmx2000m -XX:PermSize=256M -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC -XX:+UseParNewGC
  
  /proc/meminfo:
  MemTotal:     24935548 kB
  MemFree:      13564968 kB
  
  # Native memory allocation (malloc) failed to allocate 83886088 bytes for Chunk::new
  # Possible reasons:
  #   The system is out of physical RAM or swap space
  #   In 32 bit mode, the process size limit was hit
  ...
  # This output file may be truncated or incomplete.
  #
  #  Out of Memory Error (allocation.cpp:317), pid=18217, tid=275671968
  
  ---------------  T H R E A D  ---------------
  
  Current thread (0x105a1c00):  VMThread [stack: 0x10666000,0x106e7000] [id=18243]
  
  Stack: [0x10666000,0x106e7000],  sp=0x106e5ae0,  free space=510k
  Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
  V  [libjvm.so+0x724710]  VMError::report_and_die()+0x2b0
  V  [libjvm.so+0x2f68ef]  report_vm_out_of_memory(char const*, int, unsigned, char const*)+0x4f
  V  [libjvm.so+0x1576fc]  Chunk::operator new(unsigned, unsigned)+0x5c
  V  [libjvm.so+0x157c26]  Arena::grow(unsigned)+0x26
  V  [libjvm.so+0x6457e9]  resource_allocate_bytes(unsigned)+0x49
  V  [libjvm.so+0x3a03ef]  GenericGrowableArray::raw_allocate(int)+0xbf
  V  [libjvm.so+0x3402ee]  GrowableArray&lt;oopDesc*&gt;::grow(int)+0x3e
  V  [libjvm.so+0x3a62b1]  FindInstanceClosure::do_object(oopDesc*)+0x51
  V  [libjvm.so+0x2ae571]  CompactibleFreeListSpace::object_iterate(ObjectClosure*)+0x51
  V  [libjvm.so+0x38d066]  GenerationObjIterateClosure::do_space(Space*)+0x16
  V  [libjvm.so+0x2d6498]  ConcurrentMarkSweepGeneration::space_iterate(SpaceClosure*, bool)+0x18
  V  [libjvm.so+0x38be22]  Generation::object_iterate(ObjectClosure*)+0x22
  V  [libjvm.so+0x2d9f9d]  ConcurrentMarkSweepGeneration::object_iterate(ObjectClosure*)+0x4d
  V  [libjvm.so+0x37fd65]  GenCollectedHeap::object_iterate(ObjectClosure*)+0x55
  V  [libjvm.so+0x3a61fe]  HeapInspection::find_instances_at_safepoint(klassOopDesc*, GrowableArray&lt;oopDesc*&gt;*)+0x3e
  V  [libjvm.so+0x6eca91]  ConcurrentLocksDump::dump_at_safepoint()+0xf1
  V  [libjvm.so+0x6e7561]  Threads::print_on(outputStream*, bool, bool, bool)+0x201
  V  [libjvm.so+0x734927]  VM_PrintThreads::doit()+0x27
  V  [libjvm.so+0x734576]  VM_Operation::evaluate()+0x46
  V  [libjvm.so+0x733a23]  VMThread::evaluate_operation(VM_Operation*)+0x83
  V  [libjvm.so+0x733c90]  VMThread::loop()+0x190
  V  [libjvm.so+0x733780]  VMThread::run()+0x80
  V  [libjvm.so+0x5e294e]  java_start(Thread*)+0x14e
  C  [libpthread.so.0+0x54ab]  short+0x8b
  
  VM_Operation (0x0caff000): PrintThreads, mode: safepoint, requested by thread 0x09ec3800
  
  
  ---------------  P R O C E S S  ---------------
  
  Java Threads: ( =&gt; current thread )
  ...//209 Java Threads
  
  Heap
   par new generation   total 147456K, used 126550K [0x161f0000, 0x201f0000, 0x201f0000)
    eden space 131072K,  92% used [0x161f0000, 0x1d869d18, 0x1e1f0000)
    from space 16384K,  31% used [0x1e1f0000, 0x1e70be78, 0x1f1f0000)
    to   space 16384K,   0% used [0x1f1f0000, 0x1f1f0000, 0x201f0000)
   concurrent mark-sweep generation total 1884160K, used 1697819K [0x201f0000, 0x931f0000, 0x931f0000)
   concurrent-mark-sweep perm gen total 262144K, used 61769K [0x931f0000, 0xa31f0000, 0xb31f0000)
  
  Code Cache  [0xb391f000, 0xb44b7000, 0xb691f000)
   total_blobs=3924 nmethods=3719 adapters=157 free_code_cache=38272704 largest_free_block=9600
  </code></pre>