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. Android 全屏Activity以透明的对话框形式弹出

    1. styles.xml <style name="transcutestyle" parent="@android:style/Theme.DeviceDefa ...

  2. httpWebRequest获取流和WebClient的文件抓取

    httpWebRequest获取流和WebClient的文件抓取 昨天写一个抓取,遇到了一个坑,就是在获取网络流的时候,人为的使用了stream.Length来获取流的长度,获取的时候会抛出错误,查了 ...

  3. Centos 7.x系统安装后的初始化配置

    1.配置IP.网关,编辑/etc/sysconfig/network-scripts/ifcfg-eno16777736 TYPE=Ethernet BOOTPROTO=none //默认为dhcp ...

  4. zookeeper 安装的三种模式

    Zookeeper安装 zookeeper的安装分为三种模式:单机模式.集群模式和伪集群模式. 单机模式 首先,从Apache官网下载一个Zookeeper稳定版本,本次教程采用的是zookeeper ...

  5. Office2007 每次打开斗需要检查 【配置进度】

    打开C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller目录下将SETUP.EXE 重命名为 ...

  6. 解决pycharm安装包过程出现的问题:module 'pip' has no attribute 'main'

    解决pycharm安装包过程出现的问题:module 'pip' has no attribute 'main' 问题 更新pip之后,Pycharm安装package出现如下报错:module 'p ...

  7. Java 中运用DOS运行class(字节码)

    附属: -dir:例举该目录的所有文件名称 有<dir>是文件夹,没有<dir>是文件-cd: 改变目录 进入其他目录 change direction-cd\:一次性回到根目 ...

  8. CVPR2018资源汇总

    CVPR 2018大会将于2018年6月18~22日于美国犹他州的盐湖城(Salt Lake City)举办. CVPR2018论文集下载:http://openaccess.thecvf.com/m ...

  9. date 命令之日期和秒数转换

    时间转为秒数 date -d "2012-11-12 13:00:00" +"%s" 描述转为日期 date -d@1352692800 +"%Y-% ...

  10. PL/SQL常用表达式及举例(一)

    IF 判断条件 THEN 满足条件时执行语句 END IF; DECLARE v_countResult NUMBER; BEGIN SELECT COUNT(empno) INTO v_countR ...