Jump to content
  • Advertisement
Sign in to follow this  
yogeshpatel4all

Memory Allocation Error

This topic is 4829 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 .

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!