Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > Re: Memory Allo...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 11 Topic 26122 of 26955
Post > Topic >>

Re: Memory Allocation : Static or Dynamic?

by roberson@[EMAIL PROTECTED] (Walter Roberson) May 8, 2008 at 05:54 PM

In article
<4fb3e23e-d0fb-4b40-a3b9-cd8dfe957dd6@[EMAIL PROTECTED]
>,
 <swornavidhya.mahadevan@[EMAIL PROTECTED]
> wrote:

>Which allocation (Static / Dynamic) is suitable for the situation when
>we are trying to allocate for a overloaded memory when the memory is
>full and no space to allocate.
>What will happen if both the allocation is impossible.

Sounds like a homework question to me...

But anyhow: The failure of dynamic allocation has well-defined
results: all of the dynamic allocation functions have methods
of indicating that they were unable to allocate more memory. This
allows you to cleanly detect and take action when memory is full.
Static memory has no defined method of indicating failure of
allocation, so you cannot cleanly detect and take action in
such cases.

If there is a failure of static memory allocation, then *some*
systems will generate a signal that can be handled through
the signal handling mechanism, but C89 at least does not define
a signal for this condition and does not do***ent it as a
possibility, so any such signal would be an OS extension, not part of C
itself. And in C89, if the system itself raises any of the signals
defined specifically in C89, then behaviour of the program
after returning from the signal handler is undefined -- all of
the C89- defined signals are for conditions that are typically
fatal on most operating systems. (Note: if the program itself
used raise() to raise one of the C89- defined signals, then
returning from the signal handler -is- well defined.)

I would have to look up the details of the signals that C99 defines
to see if there are any of them for which returning from the signal
handler is well defined. C99 differs slightly from C89 in that
there are operations (such as overflow of a signed integer) that C89
just leaves the behaviour completely undefined, but for which C99
says that the behaviour is undefined or that the system may optionally
raise an implementation-defined signal. This is where the language
lawyers make their money, arguing about the difference between
behaviour that is -always- undefined, vs behaviour that the
implementation may define as being undefined!
-- 
  "All human knowledge takes the form of interpretation."
                                              -- Walter Benjamin
 




 11 Posts in Topic:
Memory Allocation : Static or Dynamic?
swornavidhya.mahadevan@[E  2008-05-08 09:58:37 
Re: Memory Allocation : Static or Dynamic?
Antoninus Twink <nospa  2008-05-08 19:48:06 
Re: Memory Allocation : Static or Dynamic?
roberson@[EMAIL PROTECTED  2008-05-08 18:37:36 
Re: Memory Allocation : Static or Dynamic?
Eric Sosman <Eric.Sosm  2008-05-08 15:05:47 
Re: Memory Allocation : Static or Dynamic?
pete <pfiland@[EMAIL P  2008-05-08 17:35:19 
Re: Memory Allocation : Static or Dynamic?
"Malcolm McLean"  2008-05-10 09:20:37 
Re: Memory Allocation : Static or Dynamic?
roberson@[EMAIL PROTECTED  2008-05-08 17:54:14 
Re: Memory Allocation : Static or Dynamic?
Antoninus Twink <nospa  2008-05-08 21:00:32 
Re: Memory Allocation : Static or Dynamic?
Antoninus Twink <nospa  2008-05-08 21:20:49 
Re: Memory Allocation : Static or Dynamic?
Antoninus Twink <nospa  2008-05-08 23:52:02 
Re: Memory Allocation : Static or Dynamic?
"cr88192" <c  2008-05-09 18:14:08 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 2:40:12 CDT 2008.