[MPlayer-dev-eng] [RFC] libnut demuxer API
Ivan Kalvachev
ikalvachev at gmail.com
Thu Sep 8 14:27:14 CEST 2005
2005/9/8, Reimar Döffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de>:
> Hi,
> On Wed, Sep 07, 2005 at 11:44:39PM +0200, Aurelien Jacobs wrote:
> > On Wed, 7 Sep 2005 08:45:59 +0300
> > Oded Shimon <ods15 at ods15.dyndns.org> wrote:
> > > ahem, yes, malloc :)
> > > even if you run out of ram, in linux, malloc STILL doesn't fail :P
> >
> > That's plain wrong !!
> [...]
> > aurel at homer:~/x$ gcc -Wall -o x x.c
> > aurel at homer:~/x$ ./x 100000000
> > 0x2aaaaae02010
> > aurel at homer:~/x$ ./x 1000000000
> > (nil)
>
> You have been testing whether an application can malloc any amout of
> RAM, which of course is not the case. Oded was talking about whether
> malloc can/will fail when you have no more free RAM, which is a
> different thing!
Anyway, not using malloc is radiculous.
Linux uses an optimistic allocation, that is actually allocate-on use.
The side effect is that if program allocate more than possible amount
and they claim it, there won't be enough memory. When such situation
occurs an memory must be freed, usually by killing an process
(OOM_Kill). It could be the biggest&new, or the process that tries to
use the memory.
The whole point is that it doesn't matter if libnut or the program
allocates memory. They will behave the same way.
So use malloc, check for null pointer, and be happy.
More information about the MPlayer-dev-eng
mailing list