Arduino Mega is not running after uploading long code

I have uploaded a program which is using 3 large Boolean matrices. Matrices defined fully inside methods to make them local variables to save the program memory. Any of these methods are returning none.

when only first two methods called and 3rd one commented, after the compilation it uses 11% of program space and 41% global variable in dynamic memory.

When all three methods called and compiled, it uses 11% of program space and 54% of global variable in dynamic memory.

No uploading error in both situations. but only 2 out of 3 methods can run once. if I called all 3 it stuck after uploading.

What is the possible reason for this error?
Why these matrix data spaces become global?
Is it regarding stack?

void loop () {
one ();
two ();
three ();
}

void one () {
bool x1[26][150] = { };
//process1
}
void two () {
bool x2[20][150] = { };
//process2
}
void three () {
bool x3[7][150] = { };
//process3
}

Which mega?

Arrays x1 and x2 are to big!

Mark

Arduino mega 2560.
yes big but, but its Boolean. method one and two works well. 2,& 3 are also ok. 1 & 3 are also ok.
Isn't one matrix definition cancel after next one calling as they are locally defined. ?

If only we could see your code.{sigh}

Do a bit of debugging - add a few print statements to see what is happening in your code , and see if the variables are responding how you hoped

Code is more than 9000 characters. cannot post here. check the attachment.

upload.ino (85.8 KB)

At some point, your code was not 90k long, and it was working.
Go back there, and play "spot-the-difference".
(I'm losing on my phone, so can't see your code)

A boolean occupies on byte. Local variables are not counted by the IDE; one off your arrays is around 4 kByte. Add that amount to the global memory usage and you're probably low on memory.

If you move that array to global space (just to check), what does the IDE say about memory usage?

sterretje:
A boolean occupies on byte. Local variables are not counted by the IDE; one off your arrays is around 4 kByte. Add that amount to the global memory usage and you're probably low on memory.

If you move that array to global space (just to check), what does the IDE say about memory usage?

101% of dynamic memory. when moved the largest matrix into global space. :frowning:

If you only need booleans, single bits will suffice. A bit more code, but eight times lower RAM requirement.