Re: Efficient memory allocation

Tech-Archive recommends: Fix windows errors by optimizing your registry



"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.



.



Relevant Pages

  • Re: Efficient memory allocation
    ... destructor.Alignment needed because of the known issue about memory locks ... Is there any other good way to allocate page-aligned,continuous, large ... block other than using VirtualAlloc() and 'placement-new'? ... If I use 'placement new' to construct an object in the pre-allocated ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Efficient memory allocation
    ... Is there any other good way to allocate page-aligned,continuous, large ... memory block and creating large number of page-aligned objects in that block ... other than using VirtualAlloc() and 'placement-new'? ... If I use 'placement new' to construct an object in the pre-allocated ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Application becomes slow in windows server 2003
    ... I asked the difference between heapalloc and virtualalloc because of my less ... But I am aware with the concept of page-in and page-out(under low memory ... Since calloc,malloc call heapalloc so i thought to use it directly. ... systems with same configuration, RAM size same. ...
    (microsoft.public.vc.mfc)
  • Re: Application becomes slow in windows server 2003
    ... Memory allocation is not your bottleneck. ... I asked the difference between heapalloc and virtualalloc because of my ... Since calloc,malloc call heapalloc so i thought to use it directly. ... assumption was it will improve performance(time to allocate memory). ...
    (microsoft.public.vc.mfc)
  • Re: Application becomes slow in windows server 2003
    ... I asked the difference between heapalloc and virtualalloc because of my less ... But I am aware with the concept of page-in and page-out(under low memory ... Since calloc,malloc call heapalloc so i thought to use it directly. ... systems with same configuration, RAM size same. ...
    (microsoft.public.vc.mfc)