Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

.JAR file appears to stop running

 
Yile Ku
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 208
9
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic