I am working on a program which creates a large pointer array of numbers and then performs several iterations of operations in them.
int * u = new int[N];
double * nu = new double[N];
int * nud = new int[N];
for (int i=0;i<M;i++){

     for (int i=0;i<N;i++){

     (perform some operations on nu and nud, increment a counter)

If M is small enough then there are no problems in the program. However once M is large enough I get the "unhanded exception":

std::bad_alloc at memory location 0x0026f728..

Since I am just reusing the same arrays, and since I am able to make it through a few iterations, I didn't think it could be a memory issue. If it is, is there a way I can clear the data completely after each iteration?