Re: malloc and realloc
- From: "santosh" <santosh.k83@xxxxxxxxx>
- Date: 28 Jan 2007 20:57:53 -0800
Yevgen Muntyan wrote:
santosh wrote:
tphipps@xxxxxxxxxxxxxx wrote:
At the risk of repeating myself...<snip>
On Jan 28, 4:20 pm, CBFalconer <cbfalco...@xxxxxxxxx> wrote:
Any time you see "x =realloc(x, size);" you have a potentialSo there's a memory leak for some tiny number of clock cycles until
memory leak, and you know the coder is probably inexperienced.
Exceptions exist.
abort() is called... big deal.
Some primitive systems are unable to reclaim memory lost through a
program leak. DOS and Windows 3.x series were famous for this feature.
IIRC, even Windows 95 occasionally suffered from this deficiency.
In those cases abort() call is the problem, not that single leak,
since all memory allocated elsewhere isn't freed, right?
Yes. That's why it's good practise to release resources after you've
used it.
Should a program never call abort() ?
It's fine during development and debugging, but during actual use, in
most cases, you can shut down far more gracefully than abort()ing.
How about exit(EXIT_FAILURE) and such?
Better, but still, the fact remains that he hasn't explicitly
free()'ed the memory he allocated, thus setting up a potential memory
leak.
Anyway, it was about "memory leak for some tiny number of clock cycles"
which indeed is that - a "leak" that nobody can even notice.
Except on the above mentioned systems.
.
- References:
- malloc and realloc
- From: ravi . cs . 2001
- Re: malloc and realloc
- From: Richard Heathfield
- Re: malloc and realloc
- From: tphipps
- Re: malloc and realloc
- From: CBFalconer
- Re: malloc and realloc
- From: tphipps
- Re: malloc and realloc
- From: santosh
- Re: malloc and realloc
- From: Yevgen Muntyan
- malloc and realloc
- Prev by Date: Re: (OT] - BASIC) was: Re: I have no programming experience. Would you recommend C?
- Next by Date: OT - Re: Google's latest dungheap
- Previous by thread: Re: malloc and realloc
- Next by thread: Re: malloc and realloc
- Index(es):
Relevant Pages
|