保留数组的内存 [英] reserving memory for an array

查看:73
本文介绍了保留数组的内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有10,000多个元素的大数组,那我该怎么保留内存

呢?目前我遇到了分段错误。动态预订

很好,但允许一个块用于该程序是可接受的

替代方案。

If I have a large array 10,000+ elements then how do I reserve memory
for this ? Currently I get a segmentation fault. Dynamic reservation
is good, but allowing a chunk for the program is an acceptable
alternative.

推荐答案

vf***@talktalk.net 写道:

如果我有一个10,000+元素的大数组,那我该怎么保留内存

呢?
If I have a large array 10,000+ elements then how do I reserve memory
for this ?



储备记忆是什么意思?您可以声明静态数组,

或自动数组,或动态数组。在某种意义上,所有那些保留记忆


What do you mean by "reserve memory"? You either declare a static array,
or an automatic array, or a dynamic array. All those "reserve memory"
in some sense.


目前我遇到了分段错误。
Currently I get a segmentation fault.



阅读常见问题5.8。

Read FAQ 5.8.


动态预订

很好,但是允许一个块用于该程序是可接受的

替代方案。
Dynamic reservation
is good, but allowing a chunk for the program is an acceptable
alternative.



什么是允许程序块?


V

-

请在通过电子邮件回复时删除资金''A'

我没有回复最热门的回复,请不要问

What''s "allowing a chunk for the program"?

V
--
Please remove capital ''A''s when replying by e-mail
I do not respond to top-posted replies, please don''t ask


vf***@talktalk.net 写道:

如果我有一个10,000+元素的大数组,那我该怎么保留内存

呢?目前我遇到了分段错误。动态预订

是好的,但允许程序块是可接受的

替代方案。
If I have a large array 10,000+ elements then how do I reserve memory
for this ? Currently I get a segmentation fault. Dynamic reservation
is good, but allowing a chunk for the program is an acceptable
alternative.



使用std :: vector(参见
http://www.parashift.com/c++-faq-lit...html#faq-34.1) 。 />

干杯! --M

Use std::vector (cf.
http://www.parashift.com/c++-faq-lit...html#faq-34.1).

Cheers! --M




Victor Bazarov写道:

Victor Bazarov wrote:

储备记忆是什么意思?您可以声明静态数组,

或自动数组,或动态数组。在某种意义上,所有那些保留记忆


What do you mean by "reserve memory"? You either declare a static array,
or an automatic array, or a dynamic array. All those "reserve memory"
in some sense.

目前我遇到了分段错误。
Currently I get a segmentation fault.



阅读常见问题5.8。


Read FAQ 5.8.



相信我!它是由数组引起的,因为如果我只减少

大小就不会发生。这是某种堆栈溢出,有人

告诉我这个效果的话。

Believe me! It is caused by the array, because if I only reduce the
size it does not occur. It is some kind of stack overflow, someone
told me words to that effect.


动态预订

很好,但允许程序块是可接受的

替代方案。
Dynamic reservation
is good, but allowing a chunk for the program is an acceptable
alternative.



什么是允许程序块?


What''s "allowing a chunk for the program"?



在其他编译器中/我用过的平台/语言通常是

一个或多个数字(十六进制)设置,允许你保留一个

块。您的程序的内存(可执行文件),如固定堆栈大小

或初始堆栈大小和最大堆栈大小。也许我正在制作

假设C ++编译器以相同的方式工作。

In other compilers / platforms / languages I''ve used there is usually
one or more numeric (hex) settings which allows you to reserve a
"chunk" of memory for your program (executable), like fixed stack size
or initial stack size and a max stack size. Perhaps I am making
assumptions that C++ compilers work the same way.


这篇关于保留数组的内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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