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?

Thanks!

February 22nd, 2013, 09:06 AM

GCDEF

Re: Problem with large pointer array

You don't think bad_alloc is a memory issue? How big does N have to be to fail?

February 22nd, 2013, 09:23 AM

goliath11

Re: Problem with large pointer array

N is only around 4000. What bothers me is that I get bad_alloc after completing the first few iterations. If it was a memory problem I would expect it to fail during the first initialization. If M is set <7 it runs fine, but any greater and I get the unhandled exeption.

February 22nd, 2013, 09:26 AM

GCDEF

Re: Problem with large pointer array

I don't see anything. Can you post complete code for a small program that reproduces the problem.

February 22nd, 2013, 02:40 PM

Paul McKenzie

Re: Problem with large pointer array

Quote:

Originally Posted by goliath11

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.

Well, let's see the complete program. A naked psuedo function with a call to new[] doesn't tell us anything. What if that missing code is corrupting the heap in some way?

For example, why are you using the same "i" in the nested loop as a counter in both loops? That in itself is a bug.

Quote:

If it is, is there a way I can clear the data completely after each iteration?

Post a complete program. so that we know how to analyze the problem. So far, what you posted is incomplete, and it has a bug.