Guide: How to grab a Thread Dump

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Post Reply
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Guide: How to grab a Thread Dump

Post by Lapo »

A thread dump shows the status of all threads in the JVM, very useful for troubleshooting problems at runtime.

Here's how it can be done:

From a terminal/console: (all OSes)
First we need the java process's PID.
The JDK ships with the jps utility which lists all java process ids. It's under the bin/ folder.
You can run this command:

Code: Select all

jps -l
Example result:

Code: Select all

9048 sun.tools.jps.Jps
8434 com.smartfoxserver.v2.Main
So the SFS2X PID is 8434
Then we used another JDK utility called jstack, this way:

Code: Select all

jstack 8434
... which will produce the thread dump.

More on these tools:
http://docs.oracle.com/javase/1.5.0/doc ... e/jps.html
http://docs.oracle.com/javase/1.5.0/doc ... stack.html

[/size]
Last update, Nov 27th 2012
Lapo
--
gotoAndPlay()
...addicted to flash games
sumeetbasak
Posts: 2
Joined: 04 Jun 2014, 21:54

Re: Guide: How to grab a Thread Dump

Post by sumeetbasak »

My production server does not have JDK installed so naturally it does not have the jps tool.
is there any other way to get the stack trace? or the thread dump?

My server is linux running CentOS. and i have a problem which makes me reboot the server every week!! :cry:
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Guide: How to grab a Thread Dump

Post by Lapo »

Take at look this guide. It provides a lot of details and tips to obtain detailed info:
http://docs2x.smartfoxserver.com/Advanc ... ive-server

hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Guide: How to grab a Thread Dump

Post by Lapo »

2020 UPDATE:
Since the introduction of the new HTML5 AdminTool it is possible to grab a Thread Dump directly from the Dashboard.
  • Log into the AdminTool
  • Click on the Dashboard module
  • On top of the "Active Threads" window click the Dump button.
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply