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?
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
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.
Author and all-around good cowpoke
Joined: Mar 22, 2000
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.