java-Memory and CPU troubleshooting

Source: Internet
Author: User
Tags throwable

Tag:byte    Issues    sub   str   string    youdao   rgs   []   tac   

1. The phenomenon of high CPU utilization. 2. Cause 1. The dead loop 2.JVM heap occupies too large-high frequency full-gc3. Troubleshooting 1. Use the top command to find the process with the highest CPU consumption 2. Using the TOP-HP process (the process number obtained in the previous step), Locate the thread that consumes the CPU. 3. Use the [Jstack process and jstat-gcutil process 1000 100] to find out what the thread is doing: If the line Cheng Fei a GC thread, you can find the specific code directly based on the call stack ... Otherwise, do the following. 1.jstat-gcutil PID 1000 100 Use this command to track GC recycling ... 4.jmap-dump:format=b,file=memoryfile.bin "pid" 5.sz memoryfile.bin6. Use the mat to open the Memoryfile.bin file. Then analyze the memory. Find out the memory problem resolution: 4. Actual combat        5. On-line instances          six. Example source code  import Java.util.linkedlist;import Java.util.list;import Java.util.concurrent.executorservice;import Java.util.concurrent.executors;public class Testmemory{//private static byte[] Bytearray=new byte[1024*1024*170]; private static list<object> linklist=new linkedlist<object> ();p rivate static Long count=1024*1024*240/56 ;//private static list<object> list=new copyonwritearraylist<object> ();p ublic static void Main (string[] args) throws throwable{for (int index=0;index<count;++index) {Linklist.add (nEW Object ());} Executorservice service= Executors.newfixedthreadpool (5); for (int index=0;index<5;++index) {service.submit (new Runnable () {public void run () {while (true) {try {thread.sleep (); Test ();} catch (Throwable throwable) {Throwable.print StackTrace ();}}});} System.in.read ();} private static void Test () {byte[] bytes=new byte[1024*1024]; System.out.printf (Bytes.tostring ());}}    public class Testprofile {private map<testhashcode,object> map=new Hashmap<testhashcode, Object> ();p rivate static Object Obj=new object ();p ublic static void Main (string[] args) throws Throwable {new Testprofi Le (). Test1 ();}  public void Test1 () throws throwable{

java-Memory and CPU troubleshooting

Related Article

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.