GeeCON Prague 2014*
The moose likes Performance and the fly likes .JAR file appears to stop running Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Performance
Bookmark ".JAR file appears to stop running" Watch ".JAR file appears to stop running" New topic
Author

.JAR file appears to stop running

Yile Ku
Greenhorn

Joined: Jan 27, 2011
Posts: 13
I have built a .JAR file, when I run it, it stops running at certain points. I have a linux box with 2Gig of RAM. 'top' shows the free memory at 500K. Is there a way to get a stack dump or core dump of the JVM?

Kyle
Tina Smith
Ranch Hand

Joined: Jul 21, 2011
Posts: 171
    
    5

To take a heap dump:
Run "jmap -dump <pid>" to dump the heap then use one of the other tools provided by Oracle (jvisualvm) to examine the results, which will tell you what objects were in use at the time the heap was taken. If you configure your java command-line args right you can also attach jvisualvm and monitor memory/thread/cpu usage live, but I don't remember the args to do that off the top of my head.

I'm assuming both of these programs are available in Linux JDK.


Everything is theoretically impossible, until it is done. ~Robert A. Heinlein
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12792
    
    5
Exactly what does "stops running" mean?

1. No longer accepts inputs?
2. No longer creates output?
3. No exception or error report?
4. Zero CPU utilization?

Bill
Yile Ku
Greenhorn

Joined: Jan 27, 2011
Posts: 13
THe jar file runs through a list of users and updates a database. The update includes some queries over the network. It just stops during one of the queries over the network. I go into 'top' and it is using alot of the CPU (like 99%) I am guessing it is trying to garbage collect and get more memory. I used jmap, I had to use the -F option to get a heap. I then went into jhat, but it doesn't appear to have a stack trace.
M-
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12792
    
    5
Using 99% of CPU usually means your program is stuck in a loop. Being hung in a DB query or attempt to connect to the DB would show very low CPU utilization.

No symptom you give suggests GC is the culprit, if you still suspect it why not log memory statistics after every completed update to the database.

Bill
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

Like William suggests this seems to be a case of an infinite loop that is causing high CPU utilization. You could use jstack to determine which application thread is stuck on the loop.


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
 
GeeCON Prague 2014
 
subject: .JAR file appears to stop running