This is a normal c++ question. not related to Qt but there's not one c++ forum out there that solved this problem...On running my function I encounter this

" commit_and_inc: VirtualAlloc failed"

This happens when I run these lines.
Qt Code:
  1. quadrant_4D[1][1][1][1]=getPixelCount(widths[1], heights[1], widths[2],
  2. heights[2], outputImage1);
  3. quadrant_4D[1][1][1][2]=getPixelCount(widths[2], heights[1], widths[3],
  4. heights[2], outputImage1);
To copy to clipboard, switch view to plain text mode 

When I run only the first line,
Qt Code:
  1. quadrant_4D[1][1][1][1]=getPixelCount(widths[1], heights[1], widths[2],
  2. heights[2], outputImage1)
To copy to clipboard, switch view to plain text mode 
. the VirtualAlloc problem does not occur

here is the deginition of getPixelCount
Qt Code:
  1. int getPixelCount(int x1, int y1, int x2, int y2, RGBImage image) {
  2. int count = 0;
  3. int x, y = 0;
  4. for (x = x1; x < x2; x++) {
  5. for (y = y1; y < y2; y++) {
  6. if (image(x, y) == COLOR_RGB(0,0,0)) {
  7. count++;
  8. }
  9. }
  10. }
  11. return count;
  12. }
To copy to clipboard, switch view to plain text mode