高级架构师遇到内存溢出问题是怎么解决的?

1.
2022-01-31 16:07:29.639 ERROR 1981 — [http-nio-8080-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet]: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.OutOfMemoryError: Java heap space] with root causejava.lang.OutOfMemoryError: Java heap space2. 内存溢出的问题
3. 场景模拟
// 通过无限创建自定义对象模拟内存溢出的场景@GetMapping(&
2022-01-31 16:07:29.639 ERROR 1981 — [http-nio-8080-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet]: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.OutOfMemoryError: Java heap space] with root causejava.lang.OutOfMemoryError: Java heap space4. 分析的方法
java.lang.OutOfMemoryError: Java heap spaceat com.example.demo.entity.CustomObj.<init>(CustomObj.java:11) ~[demo.jar:0.0.1-SNAPSHOT]at com.example.demo.controller.TestController.oom(TestController.java:36) ~[demo.jar:0.0.1-SNAPSHOT]at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
@GetMapping(&
4.2 jmap
jmap -histo pid |head -n 20
jmap -histo:live pid|head -n 20
** * @author liuboren * @Title: 自定义对象 * @Description: 创建该对象用于模拟OOM场景 * @date 2022/1/30 16:55 */public class CustomObj {private int[] numbers = new int[10000000];}
4.3 堆转储文件分析
4.4 arthas
4.5 jstat
jstat -gcutilpid1000
【高级架构师遇到内存溢出问题是怎么解决的?】以上就是朝夕生活(www.30zx.com)关于“高级架构师遇到内存溢出问题是怎么解决的?”的详细内容,希望对大家有所帮助!

猜你喜欢