分配静态内存? [英] Allocate Static Memory?

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

问题描述

我想知道在执行之前有多少静态内存被限制

程序启动。我会写一个大数组。大阵列有65,536

元素。数据大小是双字。静态内存将分配

256K。 256K是固定的内存大小。编译器完成编译头文件和源代码后,执行程序可能无法运行或

崩溃。操作系统可能不显示错误消息,说明,

内存不足。

动态内存可能是选项。 malloc()函数可以测试

确定分配的内存是否在运行时可用。然后,使用I / O像

fopen()和fclose()函数从硬盘驱动器读取数据并将其存储到RAM中。如果malloc()测试到
告诉内存不足,则错误消息可以在运行时显示。

请给我你的建议。在执行程序启动之前可以限制多少静态内存



-


你真的,

Bryan Parkoff

I want to know how much static memory is limited before execution
program starts. I would write a large array. The large array has 65,536
elements. The data size is double word. The static memory would allocate
256K. The 256K is a fixed memory size. After the compiler has completed
compiling header and source code, the execution program might fail to run or
crash. The operating system might do not display error message saying,
"Insufficient memory."
The dynamic memory may be the option. The malloc() function can test to
determine if allocated memory is available at run-time. Then, use I/O like
fopen() and fclose() functions to read data from the hard drive and store it
into RAM. The error message can display at run-time if malloc() tests to
tell insufficient memory.
Please give me your advice. How much static memory can be limited
before execution program starts?

--

Yours Truly,
Bryan Parkoff

推荐答案

" Bryan Parkoff" < no **** @ nospam.comwrote in message

news:48 ********************** @ roadrunner.com ...
"Bryan Parkoff" <no****@nospam.comwrote in message
news:48**********************@roadrunner.com...

我想知道在执行之前有多少静态内存被限制

程序启动。我会写一个大数组。大阵列有65,536

元素。数据大小是双字。静态内存将分配

256K。 256K是固定的内存大小。编译器完成编译头文件和源代码后,执行程序可能无法运行

或崩溃。操作系统可能不显示错误消息,说明,

内存不足。

动态内存可能是选项。 malloc()函数可以测试

以确定在运行时是否可以分配内存。然后,使用I / O

,如fopen()和fclose()函数从硬盘读取数据,并将
存储到RAM中。如果malloc()

测试告诉内存不足,则错误消息可以在运行时显示。

请给我你的建议。在执行程序启动之前可以限制多少静态内存?b
$ b
I want to know how much static memory is limited before execution
program starts. I would write a large array. The large array has 65,536
elements. The data size is double word. The static memory would allocate
256K. The 256K is a fixed memory size. After the compiler has completed
compiling header and source code, the execution program might fail to run
or crash. The operating system might do not display error message saying,
"Insufficient memory."
The dynamic memory may be the option. The malloc() function can test
to determine if allocated memory is available at run-time. Then, use I/O
like fopen() and fclose() functions to read data from the hard drive and
store it into RAM. The error message can display at run-time if malloc()
tests to tell insufficient memory.
Please give me your advice. How much static memory can be limited
before execution program starts?



您的问题没有简单的答案。这将取决于您的操作系统,编译器上的硬件,b / b

当时内存中的内存,虚拟内存有多少,和

(可能)用户限制和其他一些因素。


malloc()函数也依赖于以上所有内容。

自动内存更加有限。


查看是否可以获得一定大小的内存块的最佳方法

是尝试分配它。如果分配失败,那么你就无法获得

吧。

**来自 http://www.teranews.com **

There is no simple answer to your question. It will depend on your
hardware, on your operating system, on your compiler, on what other programs
are in memory at the time, on how much virtual memory you have, and
(possibly) on your user limit and a number of other factors.

The malloc() function is also dependent upon all of the above things.
Automatic memory is even more limited.

The best way to find out if you can get a block of memory of a certain size
is to attempt to allocate it. If the allocation fails, then you can''t get
it.
** Posted from http://www.teranews.com **


5月5日晚上10点50分, ; Bryan Parkoff < nos ... @nospam.comwrote:
On May 5, 10:50 pm, "Bryan Parkoff" <nos...@nospam.comwrote:

我想知道在执行之前有多少静态内存被限制

程序启动。我会写一个大数组。大阵列有65,536

元素。数据大小是双字。静态内存将分配

256K。 256K是固定的内存大小。编译器完成编译头文件和源代码后,执行程序可能无法运行或

崩溃。操作系统可能不显示错误消息,说明,

内存不足。

动态内存可能是选项。 malloc()函数可以测试

确定分配的内存是否在运行时可用。然后,使用I / O像

fopen()和fclose()函数从硬盘驱动器读取数据并将其存储到RAM中。如果malloc()测试到
告诉内存不足,则错误消息可以在运行时显示。

请给我你的建议。在执行程序启动之前可以限制多少静态内存?b
$ b
I want to know how much static memory is limited before execution
program starts. I would write a large array. The large array has 65,536
elements. The data size is double word. The static memory would allocate
256K. The 256K is a fixed memory size. After the compiler has completed
compiling header and source code, the execution program might fail to run or
crash. The operating system might do not display error message saying,
"Insufficient memory."
The dynamic memory may be the option. The malloc() function can test to
determine if allocated memory is available at run-time. Then, use I/O like
fopen() and fclose() functions to read data from the hard drive and store it
into RAM. The error message can display at run-time if malloc() tests to
tell insufficient memory.
Please give me your advice. How much static memory can be limited
before execution program starts?



标准中唯一指出的是托管的

环境必须允许至少65,535字节的对象

创建(C89为32,767字节)。这并不意味着可以创建多个这种大小的b $ b对象,或者必须允许多个对象总共允许这个限制,并且不指定是否限制为

可通过静态或动态分配实现。有关详细信息,您需要查看实施文件。


-

Robert Gamble

The only thing the Standard says is in this regard is that a hosted
environment must allow an object of at least 65,535 bytes to be
created (32,767 bytes for C89). This doesn''t mean that multiple
objects of this size can be created or that multiple objects totaling
this limit must be allowed and it isn''t specified whether the limit be
achievable via static or dynamic allocation. For more details you
will need to consult the documentation for your implementation.

--
Robert Gamble


Robert Gamble写道:
Robert Gamble wrote:

...

......标准说..托管的

环境必须允许创建至少65,535字节的对象
(C89为32,767字节)。
...
The ... Standard says ... that a hosted
environment must allow an object of at least 65,535 bytes
to be created (32,767 bytes for C89).



严格来说,它只表示实现必须

接受一个具有许多功能的程序。

没什么可说的,分配相同的内存的不同程序会成功。 [并不是说它很容易定义。]


所有你能说的是分配一个对象是不可移动的

大于最小尺寸。


-

彼得

Strictly speaking, it only says that an implementation must
accept one program with a number of features. There is
nothing to say that a different program allocating the same
memory will succeed. [Not that it''s an easy thing to define.]

All you can say is that it''s not portable to allocate an object
larger than the minimum size.

--
Peter


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

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