Page 1 of 1

Out of memory issues

PostPosted: Wed Nov 14, 2012 3:26 pm
by lgama
Hello. I'd like to know how to deal with the "out of memory" error when i try to compile a very large app in C++ builder XE.
thanks

Re: Out of memory issues

PostPosted: Wed Nov 14, 2012 7:30 pm
by Tracer
If this happens when you compile you probably have stack overflow. To many static objects can cause this. Declarations like

int vector[20000000];

should be avoided since these objects are on stack. Better to put them on heap:

int* vector = new int[20000000];

and delete after it's not in use, or to use smart pointers that do it for you.