Re: why no palloc() ("permanent alloc")?
- From: Rainer Weikusat <rweikusat@xxxxxxxxxxx>
- Date: Sun, 20 Jul 2008 11:25:24 +0200
rahul <rahulsinner@xxxxxxxxx> writes:
On Jul 19, 9:03 pm, Bernie Ohls <Bernie.O...@xxxxxxx> wrote:
_want_ to free. Consider exporting an environment variable; this willCan you elaborate?
result in a malloc() call and be treated as a leak.
When using putenv to add to the environment, the pointer passed as
argument is just inserted into the corresponding array. This means
that the space it is refering to must remain allocated for as long as
the new variables could still be used.
It strikes me that it would be a real benefit for a programmer to be
able to make the assertion "I'm allocating this memory and I do not plan
to free it; it needs to stick around until exit time." Such as a
These concepts have been implemented as garbage
collection in other languages viz. java, c# but do not exist
in C.
Some language runtime environments provide 'automatic memory
management'. The idea above was about adding a memory-allocating
subroutine whose semantics would imply that the allocated memory is
not going to be freed by the program for some reason. I fail to see a
connection between these two, except maybe as 'knee-jerk reaction' of
suggesting 'automatic memory management' as solution to any
conceivable memory management problem because it exists.
But without a sound technical reason to not use automatic memory
management of any sort, one should IMO spend some time asking oneself
why C is being used at all. Which would be a different discussion.
C was closely modelled around the low level stuff,
RISC processors (the ones I know of) where closely modelled in the way
C 'works'. But these didn't exist by the time C was invented and the
processors of these days had complex, unorthgonal instructions sets
intended to make it easy to program in assembly.
so both allocating and freeing memory is done by the
programmer(roughly simulating the functionality of the
machine).
That you may have some machine which 'roughly' simulates
problem-adapted memory management, mostly relying on an abundance of
memory and fast CPUs to plaster over its deficiencies (general purpose
memory allocation is still an unsolved research problem) does not
reverse-modify everything similar which existed before and alongsides
of it into 'a simulation of your machine'. A bicycle is not a
motorcycle with a human simulating the motor.
.
- References:
- why no palloc() ("permanent alloc")?
- From: Bernie Ohls
- Re: why no palloc() ("permanent alloc")?
- From: rahul
- why no palloc() ("permanent alloc")?
- Prev by Date: Re: why no palloc() ("permanent alloc")?
- Next by Date: Re: files "." and ".." from readdir()
- Previous by thread: Re: why no palloc() ("permanent alloc")?
- Next by thread: Re: why no palloc() ("permanent alloc")?
- Index(es):
Relevant Pages
|