当前位置:网站首页>Analyzing server problems using jvisualvm
Analyzing server problems using jvisualvm
2022-06-13 06:37:00 【l8487】
Problem description : A game area , No one can log in , Front end display loading 了 , The back end did not report an error .
Memory evidence collection : First of all, you should catch the memory information of the server , adopt windows The task manager finds the pid, Then open the jvisualvm, Find the corresponding pid application , Click on “ Threads ” label , Click on “ Threads dump”, You can see the working status of all internal threads of the reference program .
Then start to analyze ,
As shown in the figure above , There are multiple login threads stuck run.MemcachedRun.add(MemcachedRun.java:97) here , These login threads are waiting for the lock <0x000000078004a720>, therefore , Let's see which thread holds the lock .
As shown in the figure above ,<0x000000078004a720> The owner of this lock is also waiting for the release of another lock , This lock is <0x000000078004a6d8>, However , In the print thread dump The lock cannot be found in the message , Prove that this lock is java Internal locks , Not our own code .
So it's positioned to run.MemcachedRun.delSynObject(MemcachedRun.java:341) Look at this line of code , The code is as follows :
SynObject syn=Link.take();
This Link The definition of public static BlockingQueue<SynObject> Link = new LinkedBlockingQueue<SynObject>();
So , This lock is the lock of the system , To verify this system lock , Specially wrote a section of test code , as follows :
package utils.mytest;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import MyObj.SynObject;
public class cerun extends Thread{
public static BlockingQueue<SynObject> Link = new LinkedBlockingQueue<SynObject>();
public static void main(String[] strs){
cerun cerun=new cerun();
cerun.start();
for(int i=0;i<10;i++){
try {
System.out.println(" Start the first "+i+" Time , Data volume ="+cerun.Link.size());
if(cerun.Link.size()>0){
// Restart thread
cerun.stop();
Thread.sleep(1000);
System.out.println(" Restart thread ");
cerun=new cerun();
cerun.start();
// Delete data
cerun.delSynObject(1);
}else{
System.out.println(" No data ");
}
Thread.sleep(2);
} catch (Exception e) {
e.printStackTrace();
}
}
}
public cerun(){
}
public void run() {
while(true){
try {
for(int i=0;i<10000;i++){
SynObject SynObject=new SynObject();
SynObject.setId(1);
Link.offer(SynObject);
}
if(Link.size()>2000000){
System.out.println(" The thread ends itself ");
break;
}
} catch (Exception e1) {
e1.printStackTrace();
}
}
}
public void delSynObject(int id){
for(SynObject object : Link){
if(object.getId()==id){
Link.remove(object);
}
}
}
}
Run the above code , Output is as follows :
Start the first 0 Time , Data volume =0
No data
Start the first 1 Time , Data volume =2991
Restart thread
Then no output , Prove deadlock , see jvm Content , The important contents are as follows :
"main" prio=6 tid=0x0000000003303800 nid=0x3258 waiting on condition [0x00000000032ff000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000007d5af4d30> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:834)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:867)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1197)
at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:214)
at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:290)
at java.util.concurrent.LinkedBlockingQueue.fullyLock(LinkedBlockingQueue.java:223)
at java.util.concurrent.LinkedBlockingQueue$Itr.<init>(LinkedBlockingQueue.java:792)
at java.util.concurrent.LinkedBlockingQueue.iterator(LinkedBlockingQueue.java:778)
at utils.mytest.cerun.delSynObject(cerun.java:55)
at utils.mytest.cerun.main(cerun.java:24)
Locked ownable synchronizers:
- None
"Thread-1" prio=6 tid=0x000000000d9a6800 nid=0x1ed4 waiting on condition [0x000000000df3f000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000007d5af4d30> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:834)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:867)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1197)
at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:214)
at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:290)
at java.util.concurrent.LinkedBlockingQueue.offer(LinkedBlockingQueue.java:417)
at utils.mytest.cerun.run(cerun.java:43)
Locked ownable synchronizers:
- None
You can find main Threads and created cerun Threads are waiting for locks 0x00000007d5af4d30, and 0x00000007d5af4d30 Where have you been? , Threads dump Can't find it inside .
边栏推荐
- Wechat applet development (requesting background data and encapsulating request function)
- Using the shutter floor database framework
- Use of kotlin basic common sets list, set and map
- App performance test: (IV) power
- Kotlin collaboration -- context and exception handling
- Two uses of bottomsheetbehavior
- Relationship between fragment lifecycle and activity
- Wechat applet custom tabbar (session customer service) vant
- JetPack - - - LifeCycle、ViewModel、LiveData
- SSM integration
猜你喜欢
[FAQs for novices on the road] about technology management
Jetpack - basic use of room
AI realizes "Resurrection" of relatives | old photo repair | old photo coloring, recommended by free app
[2022 college entrance examination season] what I want to say as a passer-by
JetPack - - - Navigation
SSM framework integration -- > simple background management
The boys x pubgmobile linkage is coming! Check out the latest game posters
Huawei developer certification and deveco studio compiler Download
MFS explanation (VI) -- MFS chunk server installation and configuration
MFS explanation (V) -- MFS metadata log server installation and configuration
随机推荐
Construction and verification of Alibaba cloud server webrtc system
Uniapp (upload local pictures, preview pictures, convert Base64 format, upload audio files)
Learning records countless questions (JS)
Using the shutter floor database framework
Ijkplayer code walk through H264 unpacker application details
Multithreading tests network conditions. Machines in different network segments use nbtstat to judge whether they are powered on
十五、IO流(一)
电镀挂具RFID工序管理解决方案
Fidde breakpoint interception
【新手上路常见问答】关于技术管理
Wechat applet custom tabbar (session customer service) vant
Kotlin basic string operation, numeric type conversion and standard library functions
Ijkplayer compilation process record
Custom view subtotal
‘ipconfig‘ 不是内部或外部命令,也不是可运行的程序 或批处理文件。
JNI's bitmap grayscale image (rgba_8888 and rgb_565)
Use of kotlin basic common sets list, set and map
Scrcpy development environment construction and source code reading
Command line for database
Excel data into database