java内存溢出示例(堆溢出、栈溢出)
时间:2021-08-12 19:11:57
堆溢出:
/**
* @author LXA
* 堆溢出
*/
public class Heap
{
public static void main(String[] args)
{
ArrayList list=new ArrayList();
while(true)
{
list.add(new Heap());
}
}
}
报错:
java.lang.OutOfMemoryError: Java heap space
栈溢出:
/**
* @author LXA
* 栈溢出
*/
public class Stack
{
public static void main(String[] args)
{
new Stack().test();
}
public void test()
{
test();
}
}
报错:
java.lang.StackOverflowError
标签:java,内存
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
java poi设置生成的word的图片为上下型环绕以及其位置的实现
2023-05-23 03:12:08
![](https://img.aspxhome.com/file/2023/5/76285_0s.png)
java中staticclass静态类详解
2021-10-12 19:47:35
一篇文章带你入门Springboot沙箱环境支付宝支付(附源码)
2021-06-26 23:21:16
![](https://img.aspxhome.com/file/2023/6/67646_0s.png)
详解Spring Cloud Eureka多网卡配置总结
2023-11-09 07:33:15
C#简单读取、改变文件的创建、修改及访问时间的方法
2022-11-12 03:56:50
java用类加载器的5种方式读取.properties文件
2022-05-06 14:55:19
![](https://img.aspxhome.com/file/2023/9/75419_0s.png)
Android EditText自定义样式的方法
2021-10-06 22:37:37
![](https://img.aspxhome.com/file/2023/0/117060_0s.jpg)
Java与Scala创建List与Map的实现方式
2021-07-19 23:53:07
SpringBoot中dubbo+zookeeper实现分布式开发的应用详解
2023-09-13 19:04:45
![](https://img.aspxhome.com/file/2023/2/61502_0s.png)
Java编程技巧:if-else优化实践总结归纳
2022-04-14 09:04:20
关于QueryWrapper,实现MybatisPlus多表关联查询方式
2021-10-15 07:24:59
使用Java将一个List运用递归转成树形结构案例
2021-10-14 15:18:30
![](https://img.aspxhome.com/file/2023/5/77485_0s.jpg)
Spring原生Rpc六种的正确打开方式实现示例
2021-06-23 19:35:03
![](https://img.aspxhome.com/file/2023/7/77337_0s.png)
SpringBoot YAML语法基础详细整理
2023-04-16 14:15:30
![](https://img.aspxhome.com/file/2023/0/122180_0s.png)
Struts2拦截器登录验证实例
2021-10-26 06:47:04
![](https://img.aspxhome.com/file/2023/5/84185_0s.png)
Java读取.properties配置文件方法示例
2023-08-24 16:32:56
![](https://img.aspxhome.com/file/2023/9/58159_0s.png)
Spring Cloud下OAUTH2注销的实现示例
2023-06-01 22:54:58
![](https://img.aspxhome.com/file/2023/5/90975_0s.jpg)
C#实现滑动开关效果
2023-11-26 22:18:29
![](https://img.aspxhome.com/file/2023/3/82163_0s.jpg)
C#简单的加密类实例
2022-12-15 11:31:18
基于spring中的aop简单实例讲解
2023-10-16 21:01:10
![](https://img.aspxhome.com/file/2023/9/75449_0s.png)