There maybe several reasons why a program doesnt work in Release but Debug mode. Most common from my experience are wrong versions of third-party libraries your application may depend on (e.g. linking debug libraries in release builds).
But as you described, your program fails at some memory management task (freeing memory). This is often the case because of some false memory management in your code. The fact that it works in Debug mode doesn't really prove that your code is error free, especially when dealing with allocating and freeing memory. This is because in Debug mode the memory is allocated differently. Lets say that the Debug mode is more forgiving because more memory is allocated then is actually needed (for debugging purpose). Therefore if you try to access some memory that should be illegal (because you didnt allocate it properly) it could still work in Debug mode because of the additionaly allocated memory.
I would suggest you to look at your code and see if there maybe false allocations (by logic). In your described case i think is very unlikely that your problem is related to Project/Compiler settings.
I can also suggest you this article on CP about this topic which may be of great help to you:
Debugging Release Mode Problems[
^]
Also this one seems to be very helpfull:
Surviving the Release Version[
^]