Root error running compiled script


I’ve tried running a script with Root 4.00/08 both compiled and interpreted and while it work when I run it interpreted (with .x name.C), when I compile it (with .x name.C++) i recive just a few warnings but the script silently dies as well as the root session.
I’ve isolated the problem and if I run a script like:

void prova () {
Int_t ARRAYSIZE=100000;
Int_t A_Map7[ARRAYSIZE];
Int_t A_Ndt7[ARRAYSIZE];
Int_t A_Ngmt7[ARRAYSIZE];
cout << “step1”<< endl;
Int_t A_Map8[ARRAYSIZE];
cout << “setp2” << endl;
Int_t A_Ndt8[ARRAYSIZE];
cout << “step3” << endl;
Int_t A_Ngmt8[ARRAYSIZE];
cout << “step4” << endl;
Int_t A_Bxd7[10][ARRAYSIZE];
Int_t A_Bxg7[10][ARRAYSIZE];
Int_t A_Bxd8[10][ARRAYSIZE];
Int_t A_Bxg8[10][ARRAYSIZE];

The program crashes before cout << “step 3” << endl;
I’ve monitored the sistem memory and I’ve no memory leaks.
I’ve tried to reduce ARRAYSIZE and the program runs fine but I this big array’s size.
what can I do?

The amount of memory allocated via the stack is limited on most machines (this is a system parameter).
It is in general very bad to allocate large amounts of memory as you do in the stack.
You should use the heap instead (using new)