Skip to content

Commit 48c7b91

Browse files
committedDec 30, 2019
方法区内存溢出
1 parent ccc6882 commit 48c7b91

File tree

3 files changed

+77
-1
lines changed

3 files changed

+77
-1
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.xiaolyuh;
2+
3+
import org.springframework.cglib.proxy.Enhancer;
4+
import org.springframework.cglib.proxy.MethodInterceptor;
5+
import org.springframework.cglib.proxy.MethodProxy;
6+
7+
import java.lang.reflect.Method;
8+
9+
/**
10+
* java 方法区的内存溢出
11+
* <p>
12+
* VM Args JDK 1.6: set JAVA_OPTS=-verbose:gc -XX:PermSize10 -XX:MaxPermSize10m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=D:\dump
13+
*
14+
* @author yuhao.wang3
15+
* @since 2019/11/30 17:09
16+
*/
17+
public class MethodAreaOutOfMemoryErrorTest {
18+
19+
class MethodAreaOOM {
20+
}
21+
22+
public static void main(String[] args) {
23+
MethodAreaOutOfMemoryErrorTest h = new MethodAreaOutOfMemoryErrorTest();
24+
while (true) {
25+
Enhancer enhancer = new Enhancer();
26+
enhancer.setSuperclass(MethodAreaOOM.class);
27+
enhancer.setCallback(new MethodInterceptor() {
28+
@Override
29+
public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
30+
return methodProxy.invokeSuper(o, args);
31+
}
32+
});
33+
enhancer.create();
34+
}
35+
}
36+
}
37+
38+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.xiaolyuh;
2+
3+
import org.springframework.cglib.proxy.Enhancer;
4+
import org.springframework.cglib.proxy.MethodInterceptor;
5+
import org.springframework.cglib.proxy.MethodProxy;
6+
7+
import java.lang.reflect.Method;
8+
9+
/**
10+
* java 方法区的内存溢出
11+
* <p>
12+
* VM Args JDK 1.6: set JAVA_OPTS=-verbose:gc -XX:PermSize10 -XX:MaxPermSize10m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=D:\dump
13+
*
14+
* @author yuhao.wang3
15+
* @since 2019/11/30 17:09
16+
*/
17+
public class MethodAreaOutOfMemoryErrorTest {
18+
19+
class MethodAreaOOM {
20+
}
21+
22+
public static void main(String[] args) {
23+
MethodAreaOutOfMemoryErrorTest h = new MethodAreaOutOfMemoryErrorTest();
24+
while (true) {
25+
Enhancer enhancer = new Enhancer();
26+
enhancer.setSuperclass(MethodAreaOOM.class);
27+
enhancer.setCallback(new MethodInterceptor() {
28+
@Override
29+
public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
30+
return methodProxy.invokeSuper(o, args);
31+
}
32+
});
33+
enhancer.create();
34+
}
35+
}
36+
}
37+
38+

‎spring-boot-student-okhttp/src/main/java/com/xiaolyuh/SpringBootStudentOkhttpApplication.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
public class SpringBootStudentOkhttpApplication {
88

99
public static void main(String[] args) {
10-
SpringApplication.run(SpringBootStudentValidatedApplication.class, args);
10+
SpringApplication.run(SpringBootStudentOkhttpApplication.class, args);
1111
}
1212
}

0 commit comments

Comments
 (0)
Please sign in to comment.