关于堆栈大小的警告消息 [英] Warning message regarding stack size

查看:184
本文介绍了关于堆栈大小的警告消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Visual Studio 2010 并激活 代码分析.在我的代码中有一行在函数中分配了一些内存:

I use Visual Studio 2010 with Code Analysis activated. In my code there's a line allocating some memory in a function:

TCHAR someString[40000]; 

代码分析抛出警告信息:

The code analysis throws a warning message:

警告 C6262:函数使用了 '40000' 字节的堆栈:超过/analyze:stacksize'16384'.考虑将一些数据移到堆中

warning C6262: Function uses '40000' bytes of stack: exceeds /analyze:stacksize'16384'. Consider moving some data to heap

我想知道我是否应该认真对待警告.如果我在堆栈上分配一些内存> 16384,我是否必须面对一些真正的麻烦?或者它只是一个提醒我我必须注意我的堆栈大小的一般警告消息?据我所知,默认堆栈大小为 1MB(如果您使用 Visual Studio).

I wonder if I should take the warning serious. Do I have to face some real trouble if I allocate some memory on the stack > 16384? Or is it just a general warning message which reminds me that I have to take care for my stack size in general? As far as I know the default stack size is 1MB (if you use Visual Studio).

推荐答案

诚然,该消息可能令人困惑,因为 VS(项目属性)确实报告默认值为 1M.但是,如果您查看 警告的文本,您会注意到代码分析的限制实际上是 16k.按照该链接底部的步骤纠正警告.

Admittedly, that message can be confusing since VS (project properties) does report that the default is 1M. However, if you look at the text of the warning, you'll note that the limit is actually 16k for Code Analysis. Follow the steps at the bottom of that link to correct the warning.

这篇关于关于堆栈大小的警告消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆