473,396 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Allocate Static Memory?

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
11 3528
"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
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
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
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
>>>>"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
"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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

37
by: Curt | last post by:
If this is the complete program (ie, the address of the const is never taken, only its value used) is it likely the compiler will allocate ram for constantA or constantB? Or simply substitute the...
4
by: Franklin Lee | last post by:
Hi All, I use new to allocate some memory,even I doesn't use delete to release them. When my Application exit, OS will release them. Am I right? If I'm right, how about Thread especally on...
1
by: Bryan Parkoff | last post by:
"U_BYTE Mem;" is stored in the global variable. It contains 10 megabytes. Do run-time automatically use new keyword to allocate 10 megabytes into memory, and then zero is filled automatically...
5
by: lixiaoyao | last post by:
hi all I use matrix & vector function to allocate the space myself in c, typedef struct matrix_array newdata; struct matrix_array{ float **sy,*sxx; }; newdata ndata;//new data struct...
12
by: gc | last post by:
I am writing a function that given nx1 vector a and a nx1 b solves a system of equations f(a,c)=b for a nx1 c. While writing the function: 1] Should I allocate the memory for c within the...
6
by: Peter Hickman | last post by:
I have a program that requires x strings all of y length. x will be in the range of 100-10000 whereas the strings will all be < 200 each. This does not need to be grown once it has been created....
7
by: Michael | last post by:
Hi, What's the benefit to dynamically allocate memory? using namespace std; int main() { char* ptr; ptr="abc";
2
by: lovecreatesbea... | last post by:
If the built-in operator keyword new doesn't allocate memory on heap and it calls global operator new (::operator new) or class member operator new to do that. What are the two kinds of operator...
17
by: dtschoepe | last post by:
Hi, I have a homework project I am working on, so be forwarned, I'm new to C programming. But anyway, having some trouble with a memory allocation issue related to a char * that is a variable...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.