This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Memory usage by Java program in LINUX machine. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Memory usage by Java program in LINUX machine." Watch "Memory usage by Java program in LINUX machine." New topic
Author

Memory usage by Java program in LINUX machine.

Susan Smith
Ranch Hand

Joined: Oct 13, 2007
Posts: 224
I have a Java program that I run in LINUX machine:

/usr/lib/jvm/java/bin/java -classpath .:..... -mx2m MyJavaProgram

I want to analyze the memory usage used by this program

This article (http://virtualthreads.blogspot.com/2006/02/understanding-memory-usage-on-linux.html ) recommends "pmap" to get more accurate picture [please see code snippet for result]. It mentions that I need to look at the "writeable/private" at the bottom of the result of running pmap command. I'm really confused why it is using 225,024K. Why is this?
Originally, I thought capping the heap size would help, but I don't understand why that much memory is being used.

Venkat Sadasivam
Ranch Hand

Joined: May 10, 2008
Posts: 139
A few years back I tried with YourKit profiler it has neat GUI to present data.


“Any fool can write code that a computer can understand. Good programmers write code that humans can understand. ”<br>
-Martin Fowler
Susan Smith
Ranch Hand

Joined: Oct 13, 2007
Posts: 224
Venkat,

Thanks for your reply. I actually already use VisualVM from Java to monitor this.

Another example, I run another Java program with -mx2m option but the writeable/ private almost 140M (based on the link that I sent to you I need to look at the writeable/ private)...

So I'm confused ... it's Java actually use more memory thatn what's in heap and stack?

Should I transfer this question to Linux forum probably?
Susan Smith
Ranch Hand

Joined: Oct 13, 2007
Posts: 224
Even the smallest program like this:




has huge "writeable/private" number --> more than 100MB.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Memory usage by Java program in LINUX machine.
 
Similar Threads
java memory usage on linux
java memory usage on linux
Heap Abortion
Java hotspot error
Memory issue in servlet application in a tomcat container