• Advertisement
Sign in to follow this  

DLL question

This topic is 4553 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

Hello, i noticed that if you allocate some memory, let say the client part, and then deallocate it in the DLL you get an unhandled exception. Now i wounder why? and is it possible to deallocate something in a DLL that have been allocated somewhere else. thanks.

Share this post


Link to post
Share on other sites
Advertisement
generally speaking you don't don't want todo that, allocation/deallocation should be contained on whatever side of the dll boundry it originated from.

Share this post


Link to post
Share on other sites
If you link your dll and app against the dll version of the std runtime then each of htem will have their own seperate heap. allocating in one and deleting in another causes you to try to delete memory allocated in another heap, hence the exception.

Cheers
Chris

Share this post


Link to post
Share on other sites
Keba,

If you don't want to change this, you can write a custom memory allocator so everything comes from the same heap. But you'll have to use google on writing your own.

-brad

Share this post


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

  • Advertisement