I think the problem is this:

sizeof(var) * MAX_CELLS * MAX_CELLS * 3

there was a thread and also a mention in the manual that it does not work this way. Try

(int)sizeof(var) * MAX_CELLS * MAX_CELLS * 3

or simply

4 * MAX_CELLS * MAX_CELLS * 3