Freeing main program memory from within a dll crushes in Visual studio 2010?

Memory must be allocated and freed with the same CRT. This means in general that you should try to free memory in the same module it was allocated in to avoid these types of issues. If this isn't possible you must link to the same version of the CRT MSVC will complain if you try to link to different versions of the MS CRT, but I'm guessing that you are linking to some other version that MSVC doesn't know about.

Memory must be allocated and freed with the same CRT. This means in general that you should try to free memory in the same module it was allocated in to avoid these types of issues. If this isn't possible you must link to the same version of the CRT.

MSVC will complain if you try to link to different versions of the MS CRT, but I'm guessing that you are linking to some other version that MSVC doesn't know about.

1 If you need to allocate memory in your library and free it in your program (or vice versa), you could require the program to provide function pointers to its malloc realloc and free when initializing the library (or before calling the functions that use them, at least). This actually potentially a good idea even if you don't need have malloc and free happen in different modules, as it (for example) allows programs that use a custom allocator to have your library use that allocator as well. – David X May 21 at 7:18 Thank you Yaur and DavidX for your comments.

Yes I suppose you are right. I suspected that. In this instance I just made sure that the memory is instantiated inside the dll and freed in the dll, so for now I am safe.

But in the case that no other option is available David X's idea is pretty nice. – Lefteris May 21 at 7:28.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions