• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to get Thread dumps  RSS feed

 
Ajay Xavier
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

What are thread dumps? how to obtain it?

Regards,
Ajay.
 
Cp Baherwani
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A thread dump is a snapshot of calls made in the current thread. It can be used for backtracing or debug a method call.

Thread.dumpStack() prints the stack trace of the current thread.
 
Henry Wong
author
Sheriff
Posts: 22855
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ajay Xavier:
hi,

What are thread dumps? how to obtain it?

Regards,
Ajay.


A "thread dump" is basically a stack trace of every thread in the JVM, at the time of the dump. It is generally useful, if you have exhausted every other option. It generates too much data for my liking.

Anyway, with Unix/Linux, you can obtain the dump by sending a signal 3 to the PID of the JVM. With Windows, I believe this can be obtained via a CNTRL-BREAK, in the command windows of the JVM.

Henry
 
Naseem Khan
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Henry Wong:

With Windows, I believe this can be obtained via a CNTRL-BREAK, in the command windows of the JVM.



Hi Henry, Could you please explain your above statement.

I mean how do I obtain stack trace of all threads on windows plateform. What CNTRL-BREAK mean?

Thanks in advance

Regards

Naseem
[ June 30, 2006: Message edited by: Naseem Khan ]
 
Henry Wong
author
Sheriff
Posts: 22855
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I mean how do I obtain stack trace of all threads on windows plateform. What CNTRL-BREAK mean?


Move/Click mouse focus to the command window that is running the JVM -- assuming that you started it from the command prompt.

While holding the control key, press the break key.

Henry
 
Ajay Xavier
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyway, with Unix/Linux, you can obtain the dump by sending a signal 3 to the PID of the JVM


can you please explain how to send a signal 3 to the PID of the JVM?
 
Henry Wong
author
Sheriff
Posts: 22855
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ajay Xavier:


can you please explain how to send a signal 3 to the PID of the JVM?


Use the "ps" command to list the processes running. Go through the list to find the JVM that you want the thread dump of -- and take note of the process ID.

To send a signal 3, you need to use the kill command:

$ kill -3 <PID>

where <PID> is replaced with the actual process ID number that you obtained from the "ps" command.

BTW, it has been awhile since I did this... but I am 99.44% sure it's a signal 3...

Henry
[ June 30, 2006: Message edited by: Henry Wong ]
 
Naseem Khan
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Henry. With your help, I am able to see the stackTrace of all threads.

Here is the stack trace which I got from command prompt on windows 2k plateform.



Actually I was not able to search break key on my keyboard. I pulled out my keyboard and finally on encyclopedia I got pause and break same key.


Naseem
 
Ajay Xavier
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
$ kill -3 <PID>


The process gets killed but the thread dump is not getting printed. will it get printed in the console or written to some log file.

Regards,
Ajay.
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A brief Google tells me that Henry was correct. The thread dump should be in dump-out.log. Where that log file is created I don't know, but based upon experience I would say it's probably in the folder the process was started from.
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apparently it's platform dependent. When I send signal 3 to one of my XMLRPC servers on one of our Linux boxes I get the dump scrolled in the terminal window. I'll paste it so you have some idea of what it might look like:

 
Henry Wong
author
Sheriff
Posts: 22855
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ajay Xavier:


The process gets killed but the thread dump is not getting printed. will it get printed in the console or written to some log file.

Regards,
Ajay.


The process should actually *not* terminate. A signal 3 should only cause a thread dump. The JVM should continue running.

Don't know about all cases, but when I did this for Solaris and Redhat, it just went to wherever the JVM was sending output to.

Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!