Memory Allocation Error

Started by
3 comments, last by Evil Steve 19 years ago
hi , I M getting this error while deallocating , "If this ASSERT fails, a bad pointer has been passed in. It may be totally bogus, or it may have been allocated from another heap.The pointer MUST come from the 'local' heap." i dont know what error is about what is local heap , another heap ,bogus . if u know anything pls help me .
Computer Enggineer , Just started working in IndiaGames ltd
Advertisement
The pointer is probably bad (garbage). Or you're trying to delete memory in a DLL that was allocated in an EXE (or vice-versa).
We'll need to see code if you want us to tell you what's wrong. Also, what is the value of the pointer? (Look at it in the debugger, or output it somewhere)
Quote:Original post by yogeshpatel4all

hi ,

I M getting this error while deallocating ,

"If this ASSERT fails, a bad pointer has been passed in. It may be
totally bogus, or it may have been allocated from another heap.The pointer
MUST come from the 'local' heap."

i dont know what error is about what is local heap , another heap ,bogus .

if u know anything pls help me .


What do u mean by allocted in DLL and deallocating in EXE.
What do u mean by value of pointer.
what i have checked is pointer address.
while de allocating he address it shows is same as it get while allocating
Computer Enggineer , Just started working in IndiaGames ltd
If you're using multiple processes or threads, make sure you deallocate the object on the same process/thread you allocated it on. Before you deallocate the pointer, if it's a pointer make sure it's non-null. If it's not a pointer but an object, then make sure the object has been defined and initialized before you deallocate it.

If you could provide us with the code that specifies how you deallocate this entity, that would likely be helpful in debugging.
h20, member of WFG 0 A.D.
Quote:Original post by yogeshpatel4all
What do u mean by allocted in DLL and deallocating in EXE.
If you're usign a DLL in your application, and you allocate memory inside it, you have to call delete on the pointer from inside the EXE. You can't free memory allocated by a DLL from within the EXE, since they come from different heaps.

Quote:Original post by yogeshpatel4all
What do u mean by value of pointer.
what i have checked is pointer address.
while de allocating he address it shows is same as it get while allocating

Yeah, I meant the pointer address. But if it's the same as it is when it's allocated, it doesn't really matter (since it's definitely valid in that case)

Quote:Original post by mnansgar
If you're using multiple processes or threads, make sure you deallocate the object on the same process/thread you allocated it on. Before you deallocate the pointer, if it's a pointer make sure it's non-null. If it's not a pointer but an object, then make sure the object has been defined and initialized before you deallocate it.
Actually, new and delete are fine to call from different threads, just not different processes. Unless you're using a custom memory manager that has different heaps for each thread of course.

This topic is closed to new replies.

Advertisement