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 Performance and the fly likes Java heap and Application hang 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 » Performance
Bookmark "Java heap and Application hang" Watch "Java heap and Application hang" New topic
Author

Java heap and Application hang

Andres Delrotti
Ranch Hand

Joined: Aug 11, 2005
Posts: 134
Hello everyone,

I have this problem. After some time our application begins to hang. We figured it probably had an out of memory error or something but we couldn't find any in the logs. When we checked task manager, we noticed that when the process javaw.exe begins to reach 500MB, thats when the application starts hanging. Restarting the instance is the only way to make it work normally again.

My question is even if our maximum java heap size was set to 1.5GB in the application server admin console, why is it that our application begins to hang when it reaches memory consumption 500MB? Shouldn't it be behaving like that if it was consuming near 1.5GB already?


Thanks.
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3606
    
  60

The -Xmx parameter just limits the maximum amount of memory a Java application can get. It is possible that, if there is no memory available, the JVM process won't be able to allocate that much. However, if this was the case, I'd expect you'd see some OutOfMemoryErrors in the logs.

You might try to allocate that much memory right at the beginning with -Xms; I believe the JVM won't start if it won't be able to allocate memory requested by -Xms.
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

My question is even if our maximum java heap size was set to 1.5GB in the application server admin console, why is it that our application begins to hang when it reaches memory consumption 500MB? Shouldn't it be behaving like that if it was consuming near 1.5GB already?


How did you objectively conclude that the application hangs because of memory consumption ? Like Martin said, you should see an OOM if you run out of memory. If the application is slow after some time, it could be because of a plethora of reasons.

1. CPU usage
2. Back log of application threads
3. Costly IO operations
etc

Check for other parameters that can cause the application to misbehave.


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12760
    
    5
Exactly what happens when the application "hangs"?

1. CPU use goes to 100%
2. New requests are accepted but do not progress
3. New requests get an error message
.... etc - so many possible symptoms

Does your application call a database - in the same computer -or- elsewhere in your network

Bill
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2272
    
  28

Excessive memory usage could cause application slow down . However, as other people have mentioned there could be lot of other reasons

To rule out(or in) memory usage, you can monitor the java process in JConsole. If you go to the memory tab, JConsole will show you how much heap is being used, and how much time is spent in GC. If GC is very frequent, and/or application spends too much time in collections, you have memory issues
 
Consider Paul's rocket mass heater.
 
subject: Java heap and Application hang
 
Similar Threads
JVM memory usage in wls8.1
Java Heap Space - OutOfMemory Error
Is iAS memory intensive ?
Websphere Heap size setting and Application hang
Cannot initialize heap size greater than 1280 MB.