What is a stack overflow error?

Parameters and local variables are allocated on the stack (with reference types the object lives on the heap and a variable references that object). The stack typically lives at the upper end of your address space and as it is used up it heads towards the bottom of the address space (i.e. towards zero).

Your process also has a heap, which lives at the bottom end of your process. As you allocate memory this heap can grow towards the upper end of your address space. As you can see, there is the potential for the heap to "collide" with the stack (a bit like tectonic plates!!!).

The common cause for a stack overflow is a bad recursive call. Typically this is caused when your recursive functions doesn't have the correct termination condition, so it ends up calling itself forever. However, with GUI programming it's possible to generate indirect recursion. For example, your app may be handling paint messages and whilst processing them it may call a function that causes the system to send another paint message. Here you've not explicitly called yourself, but the OS/VM has done it for you.

To deal with them you'll need to examine your code. If you've got functions that call themselves then check that you've got a terminating condition. If you have then check than when calling the function you have at least modified one of the arguments, otherwise there'll be no visible change for the recursively called function and the terminating condition is useless.

Summary: Stack Overflow Error的更多相关文章

  1. 面试题——设计一个程序:运行报错Stack Overflow Error

    所谓Stack Overflow就是栈里面放的东西太多了,溢出了. 大家知道栈里面存放的是基本数据类型还有引用类型. 下面看这个程序 class Test { public static void m ...

  2. c++ - fcgio.cpp:50: error: 'EOF' was not declared in this scope - Stack Overflow

    c++ - fcgio.cpp:50: error: 'EOF' was not declared in this scope - Stack Overflow fcgio.cpp:50: error ...

  3. python - ImportError: No module named http.cookies error when installing cherrypy 3.2 - Stack Overflow

    python - ImportError: No module named http.cookies error when installing cherrypy 3.2 - Stack Overfl ...

  4. 【转】Visual Stdio VS 错误 error : 0xC00000FD: Stack overflow. 更改堆栈空间解决栈溢出问题

    原文见:http://www.cnblogs.com/xiangwengao/archive/2012/03/16/2399888.html 问题 给一个程序添加小功能,在debug下能正常运行,在r ...

  5. Error 0xC00000FD: Stack overflow 之 更改堆栈保留大小

    Stack  overflow  顾名思义就是堆栈内存溢出. 一.无限递归 这个要自己仔细检查一下,程序中是否含有无限递归的情况,比如下面这就是无限递归: int function(int x, in ...

  6. Stack Overflow: The Architecture - 2016 Edition

    To get an idea of what all of this stuff “does,” let me start off with an update on the average day ...

  7. 【Stack Overflow -- 原创加工、原创整理、生产实战】-- 深度复制

    一.说明 1.本程序的核心代码不是我原创的,是我在Stack Overflow上搜集后加工出来的,原作者已忘记了~ 2.这段程序是我在上海携程(2014年左右)上班时整理并在生产环境应用的,先后经历了 ...

  8. JavaScript-关于在IE下JavaScript的Stack overflow at line错误可能的原因

    1.注册表混乱使基于IE内核的浏览器无法正常显示图片尤其是png格式, 修改一下注册表(网上搜) 2.重定义了系统的触发事件名称作为自定义函数名如: onclick / onsubmit…  都是系统 ...

  9. WPF Datagrid with some read-only rows - Stack Overflow

    原文:WPF Datagrid with some read-only rows - Stack Overflow up vote 21 down vote accepted I had the sa ...

随机推荐

  1. Elasticsearch学习之深入聚合分析四---案例实战

    1. 需求:比如有一个网站,记录下了每次请求的访问的耗时,需要统计tp50,tp90,tp99 tp50:50%的请求的耗时最长在多长时间tp90:90%的请求的耗时最长在多长时间tp99:99%的请 ...

  2. 题目1460:Oil Deposit(递归遍历图)

    题目链接:http://ac.jobdu.com/problem.php?pid=1460 详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus 参考代码: ...

  3. syslinux 和 grub

    syslinux是一个功能强大的引导加载程序,而且兼容各种介质.它的目的是简化首次安装Linux的时间,并建立修护或其它特殊用途的启动盘.它的安装很简单,一旦安装syslinux好之后,sysLinu ...

  4. Mysql命令行导入sql数据

    mysqldump  是在  操作系统命令行下运行的,不是在 MySQL 命令行下运行的. 登陆数据库: 登陆本地mysql : mysql -h localhost -u root -p123456 ...

  5. docker自动开启端口转发功能

    yum -y install epel-release yum -y install docker-io service docker start docker pull haproxy # 此时自动 ...

  6. JDBC的驱动是如何加载的

    注:本文出处:http://www.cnblogs.com/jiaoyiping/ 转载请保留出处 JDBC定义了一套接口,数据库产品的提供商会实现这些接口来提供自己的数据库驱动程序,这是个很好的面向 ...

  7. Css控制网页变灰

    兼容IE chrome Firefox..... html{ filter:grayscale(%); -moz-filter:grayscale(%); -o-filter:grayscale(%) ...

  8. 有向连通图增加多少边构成强联通(hdu3836,poj1236)

    hdu3836 求出强分量后缩点处理得到分支图,对分支图的每个强连通分量统计出度和入度.需要的边数就是:统计 入度=0 的顶点数 和 出度=0 的顶点数,选择两者中较大的一个,才能确保一个强连通图. ...

  9. Python之shutil模块

    shutil 高级的 文件,文件夹,压缩包 处理模块 正常把一个文件的内容拷贝到另外一个文件 s = file("test.py")d = file("test_copy ...

  10. FZU2110 Star【计算几何】

    Overpower often go to the playground with classmates. They play and chat on the playground. One day, ...