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

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

Guide: How to grab a Thread Dump

Postby Lapo » 05 Jul 2012, 10:11

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


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

Postby sumeetbasak » 29 Sep 2014, 10:38

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: 19733
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Guide: How to grab a Thread Dump

Postby Lapo » 29 Sep 2014, 10:50

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

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 13 guests