Re: When to check the return value of malloc



On Jan 22, 2:05 am, "Malcolm McLean" <regniz...@xxxxxxxxxxxxxx> wrote:
"user923005" <dcor...@xxxxxxxxx> wrote in message
What happens if some other application (running at the same time as
your small RAM requestor) succeeds in getting RAM for video editing,
and then you ask for your small packet of RAM?
Not checking the return of malloc() is simply incompetent.
Assuming that something which can fail will always work is not a good
idea, and especially when checking is an ultra-simple operation.
BTW, 99.873% of all statistics about malloc() failure percentage are
made up out of thin air.

It depends if the video editor has deliberately tailored his request to the
amount of memory in the machine. If he has, all bets are off. If he hasn't,
then the chance of failing on the small packet rather than in the video
editor is quite small.

If you think the odds are quite small that other applications which
are not intentionally trying to allocate all of RAM can make your
malloc() fail are quite small, then I can assure you that you are
mistaken. It is not at all uncommon for people to run lots of
applications at the same time. Sometimes the applications are long-
running applications. Sometimes these applications have resource
leaks. Memory allocation failure for a large or small memory request
is not a rare occurence. I think it is very careless to assume that
any memory allocation will succeed without testing it.
.



Relevant Pages

  • Re: When to check the return value of malloc
    ... your small RAM requestor) succeeds in getting RAM for video editing, ... Not checking the return of malloc() is simply incompetent. ... It depends if the video editor has deliberately tailored his request to the amount of memory in the machine. ... then the chance of failing on the small packet rather than in the video editor is quite small. ...
    (comp.lang.c)
  • Re: C 99 compiler access
    ... for malloc() to lie. ... arbitrarily killing the program off if the memory isn't really there is no ... I don't see why I should have to impede the performance of my applications ... >> being taken to determine the maximaum aggregate RAM ...
    (comp.lang.c)
  • Re: Reduce Vista Video memory allocation
    ... That's because some of that space is used by hardware and is not ... available to the operating system and applications. ... RAM itself. ... Video needs to share the RAM address space because of performance ...
    (microsoft.public.windows.vista.general)
  • =?windows-1252?Q?http=3A=2F=2Fwww=2Eelectronicsbestseller=2Ecom__HP_Pavilion_DV?= =?windows-
    ... Product Features and Technical Details ... RAM: 2000 MB ... external DVD or music buttons to launch HP QuickPlay (which bypasses ... conferencing via VoIP and video IM chats. ...
    (rec.radio.amateur.boatanchors)
  • Re: video problems in Ubuntu
    ... I have downloaded others from the same Internet archives site and used clu ips that I made from them. ... I have some know how with video editing but this is the first time I have run into this problem. ... I can watch them in Mplayer and other media I cannot render from any of them. ... even with this amount of RAM your computer should not suddenly stop in its tracks - it will slow down but not necessarily just stop. ...
    (Ubuntu)