Memory management in Debug/Release environments

E

Epetruk

Hello,

I have a problem where an application I am working on throws an
OutOfMemoryException when I run it in Release mode, whereas it doesn't do
this when I am running in Debug.

The application is developed using C++/Managed C++ and built using VS 2003
under .NET framework 1.1.

In Debug, it uses of up to 600Mb of memory, whereas in Release it only gets
to use about 200Mb before throwing the Exception.

I've attempted to debug the Release version (by building it so that it
outputs symbols and attaching), and it appears that the application throws
the exception when it attempts to instantiate a .NET class using new. (The
managed C++ code calls a function from a library written in C# which then
attempts to do the instantiation.)

Is there any reason why the application should behave differently
Debug/Release environment with respect to memory management? Is there
setting I can change to get the Release version to use more memory before it
complains of an out-of-memory error?

If there's any further information you need me to supply, I'd be happy to do
so.

Thanks in advance,
 
V

Vijay

I've had experience with programs which would run fine on a Debug
version, but would crash in a Release version.

I noticed that there is something different about the way local
variables are initialized in the debug and release versions (or the
return value of a function that does not return anything under certain
conditions). I found that the crashes happened because I used certain
variables without initializing them.

Hope this helps.
Vijay.
 
L

Loy

Sound reasonable - release build optimize out initialization code -
esspecially in unmanaged code.

(While debug build usually even clear the memory of byte arrays when
they are allocated)

Vijay point - seem correct
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top