?
Solved

memory usage in a java program running on linux

Posted on 2006-07-17
6
Medium Priority
?
253 Views
Last Modified: 2012-05-05
I have a very simple Java program running in linux:

public class test
{

    public test()
    {}

    public static void main(String[] args)
    {
      test t1 = new test();
      t1.begin();
    }

    public void begin()
    {
       while(true)
       {
           try
           {
                System.out.println("one iteration");
                Thread.sleep(5*60*1000);
           }
           catch(Exception ex)
           { ex.printStackTrace(); }
        }
     }
}

What is the best way to find the memory used by this process in linux.

I am using the jvm property (-mx3000000) to cap the maximum memory usage to 3MB. which means that if the jvm uses more than 3MB it would throw outOfMemoryError.
I have tried to monitor this process using the JConsole and the memory does not exceed the 3MB limit.

I am aware of two commands : top and pmap

if I use the top command it shows that the process using 23 MB

and pmap command (which can be used to view the private bytes ) shows that the process is using 123 MB.
(this is just the writable/private bytes)

I am new to linux. Can anyone please explain that if the jvm property forces the process to terminate  if it uses more than the assigned memory (max memory), where do I find the explanation for the remaining memory usage.





0
Comment
Question by:rnicholus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 92

Accepted Solution

by:
objects earned 672 total points
ID: 17126514
you're only limiting the amount of heap available in the jvm, yoiu are not limiting the amount of memory the vm takes from the OS
0
 
LVL 23

Assisted Solution

by:Ajay-Singh
Ajay-Singh earned 664 total points
ID: 17127465
0
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 664 total points
ID: 17128456
0
 

Author Comment

by:rnicholus
ID: 17129837
Thank you. I will try to use the memory profiler.

freeMemory() and totalMemory() methods from the Runtime class also account for the heap and not the total memory
used by the process.


0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month10 days, 15 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question