Performance Issue probably run out of Ram

Why are you passing 1000000 to an int? The use of length in LightUpLeds() doesn't look like int to me anyway.

  lightUpLeds(drawLeds, 1000000);
void loop() {
  int drawLeds[totalNumberOfMatrices][height*width][2] = {0};

drawleds[][][] is a local array of loop(). How does that get passed to the scope of lightUpLeds()?

void lightUpLeds(int drawLeds[][height*width][2], int length){