Obtaining CPU thread usage in Java

前端 未结 2 1664
不思量自难忘°
不思量自难忘° 2021-01-02 08:49

I have a question around getting CPU utilization for a given JNI block. I\'m making some intensive CPU computation in the underlying C++ JNI native method. I\'m in the proce

2条回答
  •  不知归路
    2021-01-02 09:16

    On Linux, this method may help you:

    • Run kill -3 to get the thread dump. Thread dump will be added standard output.
    • Open the dump and search for the thread you're interested in. (You can search using class name)
    • Get the thread PID (it's in hex) and convert it to decimal.
    • Run top command.
    • Press Shift-H to enable Threads View
    • Identify the thread using decimal value you obtained above. You can see cpu / memory usage of your thread there.

提交回复
热议问题