Reputation: 23419
All,
I have a Java Memory Process which starts to take more and more memory with time. To put a Cap on the heap space usage I set -Xmx option to 512M. Slowly over a period of time the Process memory usage reached 2GB.
I have analyzed the code for possible memory leaks using various tools like MAT and YOURKIT and found no such possible leaks in the Java code. The code also makes use of One Native function which looks leak free.
I have the following questions :
thanks for the answer.
Upvotes: 0
Views: 3477
Reputation: 5784
If you suspect memory leak in your java application, you should definitely try Plumbr. It is quite good and spotting them and gives quite useful reports.
Upvotes: 1
Reputation: 121649
Let me augment my "comment" with a full-fledged "response".
If you're doing a lot of string manipulation, you should definitely not be using the "String" class. And whatever's going on, Java has many great tools (including, but not limited to, JConsole) that let you intelligently analyze the problem. Your Two New BFFs should be:
StringBuilder (manipulate strings efficiently) and
JConsole (study your program's behavior; including heap allocation and garbage collection).
And, as user643011 correctly pointed out, there are lots of other things that might conceivably "leak": including files not being closed, lots of threads using lots of stack space, etc. etc.
Here is one other good link:
Upvotes: 1
Reputation: 2393
How are you measuring memory usage?
Usually there are 3 kinds of memory usage:
The virtual memory size can become larger (several GB) than what you specified with -Xmx, but this does not do any harm. RES plus SHR is what you should be looking at.
Apart from the heap there is another class of memory usage not affected by -Xmx (permgen). But that is usually capped at a few MB. You might want to read the HotSpot GC Tuning Guide.
Upvotes: 5