Re: Allocators and memory reclamation
- From: "Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx>
- Date: Mon, 28 Jan 2008 16:15:27 +0100
On Mon, 28 Jan 2008 05:49:35 -0800 (PST), Maciej Sobczak wrote:
The problem is that my understanding conflicts with what I've just
found in AARM (13.11):
"By default, the implementation might choose to have a single global
storage pool, which is used (by default) by all access types, which
might mean that storage is reclaimed automatically only upon partition
completion."
This means that the implementation might turn the above well-behaving
procedure into a memory leak. Is this correct?
It does not leak for Deallocate is called. (It would be difficult to
formalize "leaking" otherwise than "for some Allocate there was no
Deallocate called.")
The language does not prescribe the effect of a call to Deallocate on the
program's environment. Note that it might be impossible to return once
allocated system memory back to OS. So taking it naively any program would
leak.
Can I influence this behaviour to portably ensure that memory is
reclaimed when the access type goes out of scope?
Write your own pool, which takes its memory from the standard pool or else
statically.
Another question relates to the order of finalizing objects. If the
storage pool is torn down when the access type goes out of scope, is
the order of finalizing objects guaranteed?
AFAIK, it is not. Why should it be?
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.
- Follow-Ups:
- Re: Allocators and memory reclamation
- From: Randy Brukardt
- Re: Allocators and memory reclamation
- From: Maciej Sobczak
- Re: Allocators and memory reclamation
- References:
- Allocators and memory reclamation
- From: Maciej Sobczak
- Allocators and memory reclamation
- Prev by Date: Re: Allocators and memory reclamation
- Next by Date: Concurrency and interfaces
- Previous by thread: Re: Allocators and memory reclamation
- Next by thread: Re: Allocators and memory reclamation
- Index(es):
Relevant Pages
|