This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes Memory issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Memory issue " Watch "Memory issue " New topic

Memory issue

Neeba Rebbaca
Ranch Hand

Joined: Oct 21, 2008
Posts: 159
Hi to all !!! I got a serious problem. My program(using thread) is occupying exceptionally more space(573,888k). It will create more than 80+ threads and keep running.
Please help me, in managing memory. Where all the places I have to check to sort out this issue. Thanks in advance.

Anayonkar Shivalkar

Joined: Dec 08, 2010
Posts: 1545

Hi Neeba Rebbaca,

Please TellTheDetails.

The description of issue you've given is pretty vague. It creates several questions like:
1) What those threads do?
2) Is there huge number of object creation anywhere?
3) What is need to create 80+ threads?

Unless you provide some information about business logic (code would be even better), its very difficult to fix the issue.

I hope this helps.

Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
Neeba Rebbaca
Ranch Hand

Joined: Oct 21, 2008
Posts: 159
I will receive data from GPS device for 80+ vehicles to a table for every 20 secs. So i will be checking, the backend for every 20secs and process the data.
I have 4 class files, Main.class, Loc1,Loc2,Loc3

Intially,ie., when the application starts up, based on the location, the vehicle(id) will be sent to three different class (Loc1,Loc2,Loc3)
Main class - This class will find the initial location of the vehicle and create a thread.

Loc1 , will get data from back end for every 20 secs and process and thread will go to sleep for 20 secs. after that, again i will call the method in Loc.class and
get the current location, based on the location, any of the 3 class wil be called(Loc1.class,Loc2.class,Loc3.class).
Jeff Verdegan

Joined: Jan 03, 2004
Posts: 6109

Neeba Rebbaca wrote:I will receive data from GPS device for 80+ vehicles to a table for every 20 secs...

None of that really tells us anything useful.

You mentioned that the memory used goes to about 500MB.

1) How are you determining that?

2) Does it get to that point and then stabilize, and things keep running fine? Or does it keep climbing until you get OutOfMemoryError?

3) What is the -Xmx startup parameter for your JVM?

Using that much memory is not necessarily a bad thing. If you allowed the JVM that much at startup, it's free to consume all of it before it does any GC. Additionally, it's not required to give any memory back to the OS when it does GC, so if you're looking at top or Task Manager, even though the java executable may be consuming 500 MB from the OS, your program may only be using a small fraction of that.

If you keep reducing the -Xmx value until you get to the point where it does get OOME, that will give you a rough idea of how much memory your app is actually using. Or you could put a profiler on it to see what's chewing up the memory, and how much is actually being used.

Other than that, without actually seeing the code (and we don't like large wads of code being posted here), it's impossible to say what the problem is--or if there really even is a problem at all.
Chris Hurst
Ranch Hand

Joined: Oct 26, 2003
Posts: 443

These are the things you need to google ...

(java command line options) Xmx Xms Xss VisualVM
jmap & hprof.

We really need more info to help , setting a lower Xss will help (if measuring true process size) as you have so many threads but may not be the problem, if you have one at all (need to know how you have measured the problem).

"Eagles may soar but weasels don't get sucked into jet engines" SCJP 1.6, SCWCD 1.4, SCJD 1.5,SCBCD 5
I agree. Here's the link:
subject: Memory issue
jQuery in Action, 3rd edition