Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


class in dll, deleting pointer

This topic is 5560 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 have this tiny engine of mine, at it was a set of *.cpp files, each containing some class, i used them like this:
//at top

#include "cBaseClass.h"
cBaseClass* g_pBase=NULL;

//in main()

g_pBase = new cBaseClass();

//at the end

and it all worked fine, no matter hom crappy solution that is now, i want to convert my engine to one,big dll file, so i made this:
/////////////////////////in dll.cpp

#include "cBase.h"


///////////////////////////in dll.h

#ifdef LIB_EXP
#define LIB_API __declspec(dllexport)
#define LIB_API __declspec(dllimport)

class LIB_API cBase 
the problem is, that when i compile the exec with this lib, and use the same pointer_class->thing like in the first example i get debug assertion failure on some HeapChecking routine. I figure it out, that the problem is related to the fact that the class is new''ed in dll''s heap and deleted''ed in exe''s heap hmmm, i always thought that this is the same heap...whatever... i also tried all the combinations with CRT lib (MultiThreaded,Dll,etc....) so this isn''t my problem...i''ve just run out of ideas please help....

Share this post

Link to post
Share on other sites
Dll''s get a seperate memory heap from the main program. If the object is allocated (via new) from code in the main program, it needs to be deleted there - and if it''s allocated in dll code, dll code needs to delete it.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!