title: Limit jvm process memory on ubuntu
body: <p>I know there are same questions like <a href="https://stackoverflow.com/questions/1493913/how-to-set-the-maximum-memory-usage-for-jvm">this one</a> been asked and answered. I am not satisfied with the answers so let me put into more detail messages here.</p>
  
  <p>I try to start my application with JVM OPTs: <code>-Xmx128m -Xms32m -XX:MaxPermSize=64m</code>. When the app started and I check the memory usage by typing <code>cat /proc/10413/status</code>, and I found the vmsize is more than 600512 kB! which is way bigger than my settings. I'd like to know how to limit the jvm memory usage of the process.</p>
  
  <pre><code>Name:   java
  State:  S (sleeping)
  Tgid:   10413
  Pid:    10413
  PPid:   1
  TracerPid:      0
  Uid:    1001    1001    1001    1001
  Gid:    1007    1007    1007    1007
  FDSize: 128
  Groups: 1001 1007
  **VmPeak:   728472 kB**
  **VmSize:   600512 kB**
  VmLck:         0 kB
  VmHWM:    298300 kB
  VmRSS:    280912 kB
  VmData:   647804 kB
  VmStk:       140 kB
  VmExe:        36 kB
  VmLib:     13404 kB
  VmPTE:       808 kB
  VmSwap:        0 kB
  Threads:        33
  SigQ:   0/31522
  SigPnd: 0000000000000000
  ShdPnd: 0000000000000000
  SigBlk: 0000000000000000
  SigIgn: 0000000000000000
  SigCgt: 2000000181005ccf
  CapInh: 0000000000000000
  CapPrm: 0000000000000000
  CapEff: 0000000000000000
  CapBnd: ffffffffffffffff
  Cpus_allowed:   f
  Cpus_allowed_list:      0-3
  Mems_allowed:   00000000,00000001
  Mems_allowed_list:      0
  voluntary_ctxt_switches:        3
  nonvoluntary_ctxt_switches:     2
  </code></pre>