recursion lead to out of memory
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的更多相关文章
- Allowing GPU memory growth
By default, TensorFlow maps nearly all of the GPU memory of all GPUs (subject to CUDA_VISIBLE_DEVICE ...
- SAP NOTE 1999997 - FAQ: SAP HANA Memory
Symptom You have questions related to the SAP HANA memory. You experience a high memory utilization ...
- 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 ...
- Java性能提示(全)
http://www.onjava.com/pub/a/onjava/2001/05/30/optimization.htmlComparing the performance of LinkedLi ...
- 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# ...
- debugging tools
https://blogs.msdn.microsoft.com/debugdiag/ https://blogs.msdn.microsoft.com/debuggingtoolbox/2012/1 ...
- 计算机体系结构-内存调优IPC OOMK
man ipc [root@server1 proc]# man ipcIPC(2) Linux Programmer’s Manual ...
- Linux kernel Programming - Concurrency and Race Conditions
Concurrency and Its Management Race condition can often lead to system crashes, memory leak,corrupte ...
- 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 ...
随机推荐
- Android中Socket通信案例
以下这个案例是基于TCP/UDP协议的. 服务端实现代码 基于TCP的服务端协议 // 声明一个ServerSocket对象 ServerSocket serverSocket = null; try ...
- VMWare 不能识别SD卡
打开service
- !!! FAILED BINDER TRANSACTION !!! TransactionTooLargeException
- ::): !!! FAILED BINDER TRANSACTION !!! xxxRecorder 运行40多分钟,崩溃,捕获日志 03-12 14:50:12.353: E/JavaBinde ...
- WordPress 主题开发 - (三) 开发工具 待翻译
Before we get started building any WordPress Theme, we’re going to need to get our development tools ...
- Android:通过startActivityForResult方法来得到Activity的回传值
在一些情况下,我们通过 A activity跳转到 B activity上,这时希望 A activtiy能从 B activity上得到一些返回值,这个时候我们就不能使用startActivity方 ...
- android 在标题栏加上按钮
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowF ...
- Delphi XE5教程2:程序组织
内容源自Delphi XE5 UPDATE 2官方帮助<Delphi Reference>,本人水平有限,欢迎各位高人修正相关错误! 也欢迎各位加入到Delphi学习资料汉化中来,有兴趣者 ...
- 批量修改文件后缀(Python)
近期下载了很多各种教程, 但是不幸的是后缀名都是 ".mp4", 而本人喜欢 ".rmvb" 后缀,由于有轻微洁癖, 受不了后面的 ".mp4&quo ...
- BootLoader作用
BootLoader 是系统加电后运行的第一段代码.一般它只在系统启动时非常短的时间内运行. 由OS Loader负责将所要引导的操作系统的内核映象从硬盘上读到系统RAM中,然后跳转到内核的入口点上. ...
- Linux 批量解压gz包
[root@yoon export]# vi gunzip.sh !/bin/bashpath=/export/backup ----备份文件目录路径 for i in `ls ${path}/*`d ...