• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Understanding memory usage

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Running JBoss 5.1.0GA on 2.6.18-164.el5 with Sun JDK 1.6.0_16

Xms=Xmx=1536m
XX:newSize=XX:MaxNewSize=400m
XX:MaxPermSize=304m

I was expecting this to remain well within 2.5GB, however when I run top I see RES=4GB. I don't get any OutOfMemory errors and the VM does not show any leaks. The app is simple jsp, No EJBs, No db access.

cat /proc/<pid>/status shows
VmPeak: 5323840 kB
VmSize: 5194912 kB
VmLck: 0 kB
VmHWM: 4159884 kB
VmRSS: 4159884 kB
VmData: 5094360 kB
VmStk: 84 kB
VmExe: 36 kB
VmLib: 68980 kB
VmPTE: 9128 kB

Why is so much memory being help by the process?

 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sk, welcome to Java Ranch.

I assume that you used an operating system utility to determine memory usage for the java process. Well, for a java process the memory usage is a combination of:

  • the java heap (which you set to 1.5G)
  • the permgen, which holds class-level info (add another 304MB)
  • the thread stack - each thread uses up from 512KB to 2MB of space depending on the OS, and an application server runs a large number of threads
  • the C/C++ data structures used by the JVM
  • the code for the JVM, including the executable itself and any libraries (.so, .dll) used by it


  • I probably forgot something. But when you add all that up, it could be 4GB.
     
    Sk Bali
    Greenhorn
    Posts: 2
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Peter Johnson wrote:Sk, welcome to Java Ranch.

    I assume that you used an operating system utility to determine memory usage for the java process. Well, for a java process the memory usage is a combination of:

  • the java heap (which you set to 1.5G)
  • the permgen, which holds class-level info (add another 304MB)
  • the thread stack - each thread uses up from 512KB to 2MB of space depending on the OS, and an application server runs a large number of threads
  • the C/C++ data structures used by the JVM
  • the code for the JVM, including the executable itself and any libraries (.so, .dll) used by it


  • I probably forgot something. But when you add all that up, it could be 4GB.



    Thanks Peter.

    So 1536m + 304m + 237 threads at -Xss256k is still less than 2 GB.
    That would mean that 2GB of memory is being used by the C/C++ data structures and code for JVM. That is more than even my full heap. I find that very strange.

    A similar process that I manage on Solaris 10 with similar settings and more threads does not go beyound 2.3 GB.

    Thanks for the quick response.

    Regards,
    Bali
     
    Peter Johnson
    author
    Posts: 5856
    7
    Android Eclipse IDE Ubuntu
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    This discussion might also help:
    https://coderanch.com/t/111262/Linux-UNIX/read-memory-usage-process-running

    Also, I think your question is more along the lines of "how does Linux calculate the amount of memory used by a process?" In which case this might help:
    http://virtualthreads.blogspot.com/2006/02/understanding-memory-usage-on-linux.html
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic