Recently I have noticed that one of our applications crossed the allowed threshold for creating new threads in a test server. After a talk with Ops guy, we gotta to know that it had around 5k+ (O_O) threads running already for no reason. Probably a memory leak that we can have it for another day.
For now, let me share you the way to find the process and its threads in linux.
Know the process id.
First of all, we need the process id in order to list out the threads being created by said process.
1 2 3 4 5
$ top -H -u ashokma
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 3173 ashokma 20 0 2720980 429424 99644 S 5.6 2.7 4:49.63 Compositor 3166 ashokma 20 0 2720980 429424 99644 S 4.6 2.7 1:53.81 teams
Let’s take the process teams for instance. It’s id is 3166.
List the number of threads
Using the following command we can list out the number of threads.
About Ashok: Started as Java but mutated myself with some frontend scripting skills and boom Javascript guy too. Still evolving in the vast NodeJS eco-system.
Backpacker with a bike
Trying hard to be a violinist
Reads Medium to know the buzz words and follows developer memes.