Re: Efficient memory allocation
- From: "Chris Becke" <chris.becke@xxxxxxxxx>
- Date: Wed, 28 Nov 2007 14:22:36 +0200
"Kürþat" <xx@xxxxxx> wrote in message
news:OU3Jj9aMIHA.5160@xxxxxxxxxxxxxxxxxxxxxxx
Chris,
If I use 'placement new' to construct an object in the pre-allocated
memory (allocated by VirtualAlloc()) and then delete that object, what
happens to memory space occupied by that object? Is it still valid?
delete is going to fail to delete a placement new'd object as its going to
try and de-allocate the memory from the c++ freestore - which is usually
wrapped around HeapAlloc. Because the memry wasnt allocated by HeapAlloc but
VirtualAlloc the attempt to free will fail and 'delete' might throw an
exception or something. im not sure how its meant to behave when it cant
deallocate memory.
The placement new articles should cover this, but essentially you need to
call the destructor yourself for every object you placement new.
.
- Follow-Ups:
- Re: Efficient memory allocation
- From: Kürşat
- Re: Efficient memory allocation
- References:
- Efficient memory allocation
- From: Kürşat
- Re: Efficient memory allocation
- From: Chris Becke
- Re: Efficient memory allocation
- From: Kürşat
- Efficient memory allocation
- Prev by Date: Re: Kernel Space -> User Space IPC
- Next by Date: Re: known SMB anomalies?
- Previous by thread: Re: Efficient memory allocation
- Next by thread: Re: Efficient memory allocation
- Index(es):
Relevant Pages
|