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