Create objects inside DLL and delete outside will crash?!

Sometimes, when we try to delete some objects which are created inside a dll, and the deletion will cause an access violation.

Yep, but just sometimes.

I tried and tested the idea with my colleages this afternoon. And we found out that

The key to this problem is the Runtime library to compile with the dll and your caller application. If they use different Runtime library, you will have problem in clearing the memory outside the dll.

So, for the sake of safe coding, we should handling all the creation and deletion inside the dll.

posted on 2008-09-18 16:17  SigEric  阅读(468)  评论(0编辑  收藏  举报

导航