By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,649 Members | 2,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,649 IT Pros & Developers. It's quick & easy.

Allocate Static Memory?

P: n/a
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
Jun 27 '08 #1
Share this Question
Share on Google+
11 Replies


P: n/a
"Bryan Parkoff" <no****@nospam.comwrote in message
news:48**********************@roadrunner.com...
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?
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 **
Jun 27 '08 #2

P: n/a
On May 5, 10:50 pm, "Bryan Parkoff" <nos...@nospam.comwrote:
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?
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
Jun 27 '08 #3

P: n/a
Robert Gamble wrote:
...
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
Jun 27 '08 #4

P: n/a
On 6 May, 03:50, "Bryan Parkoff" <nos...@nospam.comwrote:
* * I want to know how much static memory is limited before execution
program starts.
this is platform (OS + hardware) specific.
>*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. *
this isn't an enormous amount on a modern system.
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. *
what do mean "might"? Does it crash? always? sometimes?
The operating system might do not display error message saying,
"Insufficient memory."
"might"? I think you might be using non-standard english.

Look, 256k is a *tiny* amount of memory (unless you are
programming a toaster). Are you certain its a memory problem?
Try reucing the static memory to a much smaller amount.
Does it still crash? It may not be a memory problem.

Is your code small enough to post here?

<snip>
--
Nick Keighley
Jun 27 '08 #5

P: n/a
>>>>"BP" == Bryan Parkoff <no****@nospam.comwrites:

BP I want to know how much static memory is limited before
BPexecution program starts.

This is system-specific. It definitely varies based on hardware and
operating system, and may also vary by compiler even when the hardware
and operating system are the same.

BPThe dynamic memory may be the option. The malloc() function
BPcan test to determine if allocated memory is available at
BPrun-time. Then, use I/O like fopen() and fclose() functions
BPto read data from the hard drive and store it into RAM. The
BPerror message can display at run-time if malloc() tests to
BPtell insufficient memory. Please give me your advice.

In theory, sure. In practice, not so much. Some environments may
restrict the amount of memory you have available (such as per-process
limits in BSD); others may tell you there is memory available when
there is not (such as overcommitting in Linux).

My advice is to figure out what problem you are *really* trying to
solve and to solve that problem instead.

Charlton
--
Charlton Wilbur
cw*****@chromatico.net
Jun 27 '08 #6

P: n/a
"Bryan Parkoff" <no****@nospam.comwrote in message
news:48**********************@roadrunner.com...
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?
This is off-topic wrt your question, but you can build an allocator on a
plurality of threads stack spaces... I did a memory allocation scheme in an
environment that did not have a heap. IIRC, the OS was an older version of
Quadros on ARM9. No, heap, but each Quadros Task had stack space. So, I
built the heap on a per-thread/task allocation algorithm. Something like:

http://groups.google.com/group/comp....c825ec9999d3a8

But it used bin-sema for locks instead of atomic operations. The only atomic
operation available on the ARM9 is a SWP instruction. I also used some stack
space for a globally shared heap. The entire allocation system was based on
task stacks.

Jun 27 '08 #7

P: n/a
Nick Keighley wrote:
[256 KiB] isn't an enormous amount on a modern system.
Indeed!

How to use a terabyte of RAM
http://lwn.net/Articles/273030/
Jun 27 '08 #8

P: n/a
Noob wrote:
Nick Keighley wrote:
>[256 KiB] isn't an enormous amount on a modern system.

Indeed!

How to use a terabyte of RAM
http://lwn.net/Articles/273030/
Systems with >1TB of RAM have been around for a while, no real challenge
for Oracle to fill it....

--
Ian Collins.
Jun 27 '08 #9

P: n/a
Ian Collins wrote:
Systems with >1TB of RAM have been around for a while
I had *affordable* systems in mind :-)

(Going on a tangent.)

http://www.sgi.com/products/servers/altix/4000/

"It supports up to 512 sockets under one instance of Linux and as
much as 128TB of globally shared memory."

I'm confused. Assuming 8-GiB DIMMs, how does one fit 16384 DIMMs
in a single system? How does one fit 512 CPUs in a single system?

Is the system as big as a large fridge with a huge backplane, and
tens of daughter boards which accept DIMMs and CPUs?

What I had in mind was a system with a single ATX motherboard.
I think 16 DIMM slots is the maximum, or I am mistaken?
e.g. http://www.tyan.com/product_board_detail.aspx?pid=560

16x8 = 128 GiB which still is a nice number.
Jun 27 '08 #10

P: n/a
Noob wrote:
Ian Collins wrote:
>Systems with >1TB of RAM have been around for a while

I had *affordable* systems in mind :-)

(Going on a tangent.)

http://www.sgi.com/products/servers/altix/4000/

"It supports up to 512 sockets under one instance of Linux and as
much as 128TB of globally shared memory."

I'm confused. Assuming 8-GiB DIMMs, how does one fit 16384 DIMMs
in a single system? How does one fit 512 CPUs in a single system?
It's a blade system with fancy interconnects.

If you want to see a (big!) single box system, try
http://www.sun.com/servers/highend/s...e25k/specs.xml

--
Ian Collins.
Jun 27 '08 #11

P: n/a
Noob wrote:
Nick Keighley wrote:
>[256 KiB] isn't an enormous amount on a modern system.

Indeed!
I can remember being very grateful when I got a second 4k bytes of
memory. 1968 or so. It cost about $1500. Shortly afterward a
CP/M machine with 62k of main memory was a very powerful beastie.
About 2000 I was working with a PIC chip, which had a staggering
256 bytes of main memory available. No expansion, although we
could build an i/o system to address a full 64k externally. Just
fill the address register (2 bytes), then either read or write a
whole byte. This ate up at least 3 of the basic 256 memory.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
** Posted from http://www.teranews.com **
Jun 27 '08 #12

This discussion thread is closed

Replies have been disabled for this discussion.