   memory problem with exe and dll
  I have the following problem: sometimes an object that lies on a dll needs to resize its memory,but when this event is triggered from the exe file, it will create the memory on the exe part.when it then tries to free the memory on destruction in the dll, it crashes.For example:I have a string object, when I want to read in a string from the file, I do:void test( ogFile *file ) {ogString mystring;file-&gt;ReadString(mystring);}now, file is on the exe part, while the test function is on the dll part.now file->ReadString reads a string from the open file, and stores into the string,but when the string needs to resize its memory, it gets allocated on the exe part.when test is done, it tries to free this memory, and crashes.Similar things happened a few times already, and I'm unsure how to solve this problem.I found that adding the keyword virtual to the function that does the allocation,it is fixed, but that can't be the right way to solve it, right ?   
  When your string is properly exported from the dll, all calls to new/delete should happen inside the CRT linked against the dll, not the executable, no matter who is calling a function that resizes the string.Is your string class not exported (maybe because it's templated)? Posting that code might be usefull to figure out the problem.   ;  the string class is shared code, its available in both exe and dll.It's not a template.code is available here:http://oglib.svn.sourceforge.net/viewvc/oglib/Source/the ogShared part is included in both the exe and the dll.   ;  You need both the DLL and thge EXE to link to the DLL version of the CRT. That way, you get one instance of the CRT in your process, and one heap.Failing that, if memory is allocated from within the EXE, it'll be allocated from the EXEs CRT heap, and if it's allocated from within the DLL, it'll be allocated from the DLLs CRT heap. Because those are two separate heaps, you can't allocate from one and free in another.If you create a string in the EXE, and pass it to the DLL, where it's modified, you'll need to allocate memory in the EXE and free it (and re-allocate) in the DLL.But then again, using the DLL version of the CRT will fix this - but also mean that the EXE and DLL must use the exact same CRT version.   ;  omg, never thought linking static would cause such problems.Thanx, works like a charm now!   