PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.c > Allocate Static Memory?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Allocate Static Memory?

Réponse
 
LinkBack Outils de la discussion
Vieux 06/05/2008, 03h50   #1
Bryan Parkoff
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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


  Réponse avec citation
Vieux 06/05/2008, 04h03   #2
Dann Corbit
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Allocate Static Memory?

"Bryan Parkoff" <nospam@nospam.com> wrote in message
news:481fc7cd$0$7692$4c368faf@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 **
  Réponse avec citation
Vieux 06/05/2008, 04h13   #3
Robert Gamble
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Allocate Static Memory?

On May 5, 10:50 pm, "Bryan Parkoff" <nos...@nospam.com> wrote:
> 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
  Réponse avec citation
Vieux 06/05/2008, 05h24   #4
Peter Nilsson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Allocate Static Memory?

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
  Réponse avec citation
Vieux 06/05/2008, 10h00   #5
Nick Keighley
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Allocate Static Memory?

On 6 May, 03:50, "Bryan Parkoff" <nos...@nospam.com> wrote:

> 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
  Réponse avec citation
Vieux 06/05/2008, 18h58   #6
Charlton Wilbur
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Allocate Static Memory?

>>>>> "BP" == Bryan Parkoff <nospam@nospam.com> writes:

BP> I want to know how much static memory is limited before
BP> execution 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.

BP> The dynamic memory may be the option. The malloc() function
BP> can test to determine if allocated memory is available at
BP> run-time. Then, use I/O like fopen() and fclose() functions
BP> to read data from the hard drive and store it into RAM. The
BP> error message can display at run-time if malloc() tests to
BP> tell 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
cwilbur@chromatico.net
  Réponse avec citation
Vieux 06/05/2008, 21h48   #7
Chris Thomasson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Allocate Static Memory?

"Bryan Parkoff" <nospam@nospam.com> wrote in message
news:481fc7cd$0$7692$4c368faf@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.

  Réponse avec citation
Vieux 07/05/2008, 09h28   #8
Noob
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Allocate Static Memory?

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/
  Réponse avec citation
Vieux 07/05/2008, 09h45   #9
Ian Collins
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Allocate Static Memory?

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.
  Réponse avec citation
Vieux 07/05/2008, 10h21   #10
Noob
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Allocate Static Memory?

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.
  Réponse avec citation
Vieux 07/05/2008, 10h32   #11
Ian Collins
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut [OT] Re: Allocate Static Memory?

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.
  Réponse avec citation
Vieux 07/05/2008, 17h18   #12
CBFalconer
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Allocate Static Memory?

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 **
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 19h16.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,18088 seconds with 20 queries