Java process consumes high system memory, troubleshooting

Source: Internet
Author: User


Fault: Recently received the production server alarm sms and mail, the alarm content is: Memory utilization is higher than 70%.


    1. Use the top command to view system resource Usage, command:top




      You can see that the process memory usage of Java is high, and the memory utilization of Java process reaches 70%+



2. Locating threading issues (viewing the thread condition of the 9718 process by command), command:PS P 9718-l-o pcpu,pmem,pid,tid,time,tname,cmd

From this you can see that this pid:9718 process produces a lot of threads. Next, you can view the memory-used stack through Jstack.


3. View the memory-used stack: Here we pick the tid=9720 thread for analysis, first we need to convert the ID 9731 to 16 binary. You need to enter the following command

printf "%x\n" 9731


You need to use the 16 binary 2603


4. Print the stack information for PID 9718 to Jstack.log, command:jstack-l 9718 > Jstack.log



5. View stack information file, command: Vim Jstack.log


The search for TID is 2603 related information.

You can see that the thread status is: Waiting. see a large number of Java Thread state by looking at file analysis .

It indicates that it is waiting for another condition to happen, to wake itself up, or simply that it is called sleep (N).

At this point the thread state is roughly the following:

Java.lang.Thread.State:WAITING (parking): Always wait for that condition to happen;

Java.lang.Thread.State:TIMED_WAITING (parking or sleeping): timed, that condition does not come, also will wake themselves regularly.


6. Code optimization: Send files to development. Optimize the thread

Java process consumes high system memory, troubleshooting

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.