There are two storage areas involved: the stack and the heap. The stack is where the current state of a method call is kept (ie local variables and references), and the heap is where objects are stored. The Hotspot documentation says that on Linux 64-bit each thread has a stack of 1024kB by default. The heap can be made arbitrary big, and today it's in the order of GB.

A recursive method uses both the stack and the heap. Which one you run out of first depends on the implementation. As an example, consider a method which needs thousands of integers: if they are declared as local variables, ie:

publicvoid stackOverflow(){int a_1;int a_2;int a_3;// ...int a_10_000_000;}

your program will crask with a StackOverflowError. On the other hand, if you organize your integers in an array, like:

publicvoid outOfMemory(){int[] integers =newint[10*1000*1000];}

the heap will be filled soon, and the program will end with an OutOfMemoryError. In neither case the memory is corrupted or data overridden.

Solution:

need to switch to a disk based structure, a database or a memory mapped hashtable.

recursion lead to out of memory的更多相关文章

  1. Allowing GPU memory growth

    By default, TensorFlow maps nearly all of the GPU memory of all GPUs (subject to CUDA_VISIBLE_DEVICE ...

  2. SAP NOTE 1999997 - FAQ: SAP HANA Memory

    Symptom You have questions related to the SAP HANA memory. You experience a high memory utilization ...

  3. detect data races The cost of race detection varies by program, but for a typical program, memory usage may increase by 5-10x and execution time by 2-20x.

    小结: 1. conflicting access 2.性能危害 优化 The cost of race detection varies by program, but for a typical ...

  4. Java性能提示(全)

    http://www.onjava.com/pub/a/onjava/2001/05/30/optimization.htmlComparing the performance of LinkedLi ...

  5. 2.5 – Garbage Collection 自动垃圾回收 Stop-the-world vs. incremental vs. concurrent 垃圾回收策略

    2.5 – Garbage Collection  自动垃圾回收 Lua 5.3 Reference Manual http://www.lua.org/manual/5.3/manual.html# ...

  6. debugging tools

    https://blogs.msdn.microsoft.com/debugdiag/ https://blogs.msdn.microsoft.com/debuggingtoolbox/2012/1 ...

  7. 计算机体系结构-内存调优IPC OOMK

    man ipc [root@server1 proc]# man ipcIPC(2)                     Linux Programmer’s Manual             ...

  8. Linux kernel Programming - Concurrency and Race Conditions

    Concurrency and Its Management Race condition can often lead to system crashes, memory leak,corrupte ...

  9. 02 Go 1.2 Release Notes

    Go 1.2 Release Notes Introduction to Go 1.2 Changes to the language Use of nil Three-index slices Ch ...

随机推荐

  1. Linux驱动编程--基于I2C子系统的I2C驱动的Makefile

    ifeq ($(KERNELRELEASE),) KERNELDIR ?= /lib/modules/$(shell uname -r)/buildPWD := $(shell pwd) TEST = ...

  2. SAP存货账龄分析之库存获取

    前段时间上面要求做一个历史库存账龄分析,取历史数据的时候一直纠结于用mchb/mchbh/mska/mskah等实时和历史库存表,然而试来试去还是不能成功,于是决定DEBUG下MB5B的源代码,测试了 ...

  3. 使用DriverManager获取数据库连接的一个小改进

    由于使用DriverManager获取数据库连接时,由于DriverManager实现类中有一段静态代码块,可以直接注册驱动,且可以同时管理多个驱动程序 所以当换数据库连接时需要指定不同的数据库,那么 ...

  4. composer安装yii2或者laravel报错

    大概的信息就是提示让登陆github,然后就报错了 Could not fetch https://api.github.com/authorizations, enter your GitHub c ...

  5. struts2结构图

  6. 说Win7激活

    今天晚上给电脑来了个强制关机,后来打开后提示我,该Windos不是正版,顿时无语.诺,看下图:我的桌面也全部变成黑色了…… 后来一想……哦,应该是我的安装光盘里的激活工具激活的不彻底,或者说只是给我激 ...

  7. JNI 学习笔记

    JNI是Java Native Interface的缩写,JNI是一种机制,有了它就可以在java程序中调用其他native代码,或者使native代码调用java层的代码.也 就是说,有了JNI我们 ...

  8. Operating Cisco Router

    Operating Cisco Router consider the hardware on the ends of the serial link, in particular where the ...

  9. 终于成为博客员的一员了,这是我的第一篇博文,写一个关于ul li内容宽度的问题和解决方案

    第一次写博文,写一个刚才遇到的问题吧. 关于ul li文字长度不固定,一行显示多列.当指定宽度时,文字长度超过指定的li宽度时解决方案: 如下代码 <h4>发送对象(共10个会员)< ...

  10. WPF-控件-ListView

    <Window x:Class="DataTemplate2.MainWindow" xmlns="http://schemas.microsoft.com/win ...