Macro crashes after defining a large matrix

I have a Macro that works fine up to the line where I define a matrix in the form float V[19999][19999].
The only thing I do to run my macro is root -l macro.cpp. This shows a few debugging cout I have, and stops at the definition of the matrix. It exits ROOT with no error message.

This is a code that was given to me using arrays (for smaller dimension), so I would really like to continue using this arrays instead of vectors

You try to allocate 19999199994 = 1,599,840,004 bytes on the stack. You cannot. If you don’t want to use vectors, try to allocate the matrix on the heap:

float **V = new float*[19999];
for (int i = 0; i < 19999; ++i)
    V[i] = new float[19999];

and then, don’t forget to delete it once you’re done:

for (int i = 0; i < 19999; ++i)
    delete [] V[i];
delete [] V;

If you don’t know the difference between the stack and the heap, you can read this (for example)

Thank you so much! I didn’t know the difference and I learnt something new. Just a good practice question: If my variable is used during the entire macro, should I still have to use delete to return the memory?

Yes, when you allocate memory, it’s a good practice to free it at the end, or whenever you don’t need it anymore