View Java objects that take up more memory in the Linux environment
- Use top to view the top java processes
- View the top 30 java objects that take up more memory jmap -histo:live [pid] | head -30, or export to a file:
jmap -dump:format=b,file=/filepath/heap.bin pid
Note: If the current user is not the user who started the java process, using the jmap command will report the following error: well-known file is not secure
Use su to switch to the java user and then execute;
View all users under the root user:
cat /etc/passwd
If there are many system classes in the query result, you can use the grep command to further filter out the objects in the business:
E.g:
jmap -histo:live 54968 |grep com.XXX| head -30
jmap -dump:format=b,file=/filepath/heap.bin pid
jmap -histo 54968|grep com.XXX |sort -k 2 -g -r|less