标签:not double com intern dem ide oct 项目上线 ken
在java服务项目上线之后经常会出现宕机的情况
1.查到服务进程号
[root@wms ~]# ps -ef|grep java root 6399 6069 0 08:57 pts/2 00:00:00 grep --color=auto java root 25374 1 0 Oct17 ? 00:21:19 /usr/local/jdk/jre/bin/java -Djava.util.logging.config.file=/home/tomcat-wmsweb/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xms3072m -Xmx3072m -Xss512K -XX:PermSize=256m -XX:MaxPermSize=512m -Djdk.tls.ephemeralDHKeySize=2048 -Djava.endorsed.dirs=/home/tomcat-wmsweb/endorsed -classpath /home/tomcat-wmsweb/bin/bootstrap.jar:/home/tomcat-wmsweb/bin/tomcat-juli.jar -Dcatalina.base=/home/tomcat-wmsweb -Dcatalina.home=/home/tomcat-wmsweb -Djava.io.tmpdir=/home/tomcat-wmsweb/temp org.apache.catalina.startup.Bootstrap start root 25401 1 2 Oct17 ? 03:14:13 /usr/local/jdk/jre/bin/java -Djava.util.logging.config.file=/home/tomcat-wms/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xms3000m -Xmx3000m -Xss512K -XX:PermSize=256m -XX:MaxPermSize=512m -XX:-UseGCOverheadLimit -Djdk.tls.ephemeralDHKeySize=2048 -Djava.endorsed.dirs=/home/tomcat-wms/endorsed -classpath /home/tomcat-wms/bin/bootstrap.jar:/home/tomcat-wms/bin/tomcat-juli.jar -Dcatalina.base=/home/tomcat-wms -Dcatalina.home=/home/tomcat-wms -Djava.io.tmpdir=/home/tomcat-wms/temp org.apache.catalina.startup.Bootstrap start [root@wms ~]#
2、查看内存使用情况
[root@wms ~]# jmap -heap 25401 Attaching to process ID 25401, please wait... Debugger attached successfully. Server compiler detected. JVM version is 25.211-b12 using thread-local object allocation. Parallel GC with 4 thread(s) Heap Configuration: MinHeapFreeRatio = 0 MaxHeapFreeRatio = 100 MaxHeapSize = 3145728000 (3000.0MB) NewSize = 1048576000 (1000.0MB) MaxNewSize = 1048576000 (1000.0MB) OldSize = 2097152000 (2000.0MB) NewRatio = 2 SurvivorRatio = 8 MetaspaceSize = 21807104 (20.796875MB) CompressedClassSpaceSize = 1073741824 (1024.0MB) MaxMetaspaceSize = 17592186044415 MB G1HeapRegionSize = 0 (0.0MB) Heap Usage: PS Young Generation Eden Space: capacity = 607649792 (579.5MB) used = 607649792 (579.5MB) free = 0 (0.0MB) 100.0% used From Space: capacity = 213385216 (203.5MB) used = 0 (0.0MB) free = 213385216 (203.5MB) 0.0% used To Space: capacity = 201326592 (192.0MB) used = 0 (0.0MB) free = 201326592 (192.0MB) 0.0% used PS Old Generation capacity = 2097152000 (2000.0MB) used = 2097149664 (1999.9977722167969MB) free = 2336 (0.002227783203125MB) 99.99988861083985% used 121339 interned Strings occupying 10592008 bytes.
发现 Eden Space 100.0% used
PS Old Generation 100.0% used
确认为内存溢出
接下来我们需要查看到底是那个大对象造成的这个问题
由于堆内对象信息太多,因此需要输出到问题中查看
[root@wms ~]# jmap -histo:live 25401 >aaa.log
查看大对象信息
[root@wms ~]# vim aaa.log num #instances #bytes class name ---------------------------------------------- 1: 23798913 925276392 [C 2: 23791642 570999408 java.lang.String 3: 879806 201469128 [Ljava.lang.Object; 4: 717239 189351096 com.demo.inventory.query.GetTaskCountQueryItem 5: 5247003 125928072 java.lang.Double 6: 932106 82025328 java.lang.reflect.Method 7: 2144995 68639840 java.util.HashMap$Node 8: 1457567 46642144 java.sql.Timestamp 9: 725212 40611872 org.hibernate.engine.EntityEntry 10: 725213 34810224 org.hibernate.engine.EntityKey 11: 180443 26468992 [Ljava.util.HashMap$Node; 12: 549431 26372688 org.aspectj.weaver.reflect.ShadowMatchImpl 13: 655720 26228800 java.util.LinkedHashMap$Entry 14: 239773 25712128 java.lang.Class 15: 780484 24975488 org.apache.commons.collections.SequencedHashMap$Entry 16: 1535589 24569424 java.lang.Integer 17: 656230 20999360 java.util.concurrent.ConcurrentHashMap$Node 18: 869529 20868696 java.util.ArrayList 19: 822486 20851440 [Ljava.lang.String; 20: 66016 19964336 [B 21: 549431 17581792 org.aspectj.weaver.patterns.ExposedState 22: 705540 15311776 [Z 23: 549431 11702568 [Lorg.aspectj.weaver.ast.Var; 24: 725212 11603392 org.hibernate.util.IdentityMap$IdentityKey 25: 158941 8900696 java.util.LinkedHashMap 26: 324828 7247936 [I 27: 162778 6511120 java.lang.ref.SoftReference 28: 476 6288080 [Ljava.util.concurrent.ConcurrentHashMap$Node; 29: 110595 5308560 java.util.HashMap 30: 155487 4975584 java.lang.ref.WeakReference 31: 16090 3732880 com.demo.inventory.query.WmInvLotLocTraceIdQueryItem 32: 163337 3313312 [Ljava.lang.Class; 33: 41098 3287840 java.lang.reflect.Constructor 34: 51249 3279936 org.hibernate.mapping.Column 35: 81913 3276520 java.util.WeakHashMap$Entry 36: 35571 3047840 [[Ljava.lang.String; 37: 51247 2869832 org.hibernate.mapping.Property 38: 51249 2459952 org.hibernate.mapping.SimpleValue 39: 49720 1988800 org.hibernate.annotations.common.reflection.java.JavaXProperty 40: 48352 1934080 org.hibernate.tuple.StandardProperty 41: 78677 1888248 java.beans.MethodRef
由上可知com.demo.inventory.query.GetTaskCountQueryItem 导致内存过大,应优化处理。
本博文来源于:https://blog.csdn.net/weixin_43159039/article/details/102676161
标签:not double com intern dem ide oct 项目上线 ken
原文地址:https://www.cnblogs.com/Small-sunshine/p/11733881.html