P
Pete
I've run into an interesting memory problem. I think I'm running out of
heap space, but I'm not sure....
I'm creating two new arrays like such....
pImage = new UBYTE [nImageSize];
pImageTemp = new UBYTE [nImageSize];
where nImageSize = 262144. new is NOT returning NULL at this point, which
gives me the impression that new succeeded.
After a little error checking, the code goes to the following statement....
for(int tries = 0;tries <10 && fread (pImageTemp, sizeof (UBYTE),
nImageSize, pFile) != nImageSize; tries++)
{
fclose (pFile);
if (tries == 9)
{
delete [] pImage;
delete [] pImageTemp;
return 0;
}
Now given a pFile named "cloak.tga" (which BTW, was opened succesfully),
this code will successfully load "cloak.tga" most of the time. However, at
an arbitrary point ( say the 4th or 5th time I call this code) fread will
fail. Once it fails it enters the above loop to try freading 9 more times.
Once it fails the first time it will ALWAYS fail the next 9 times. At this
point, when
delete [] pImageTemp;
is called, I get the following error message:
HEAP[Bruteball.exe]: Heap block at 070ADB18 modified at 070ADF50
past requested size of 430
So am I running out of Heap space? If so, why isn't new returning NULL?
Anyone have any ideas of how to fix this issue?
Thanks,
-Pete
heap space, but I'm not sure....
I'm creating two new arrays like such....
pImage = new UBYTE [nImageSize];
pImageTemp = new UBYTE [nImageSize];
where nImageSize = 262144. new is NOT returning NULL at this point, which
gives me the impression that new succeeded.
After a little error checking, the code goes to the following statement....
for(int tries = 0;tries <10 && fread (pImageTemp, sizeof (UBYTE),
nImageSize, pFile) != nImageSize; tries++)
{
fclose (pFile);
if (tries == 9)
{
delete [] pImage;
delete [] pImageTemp;
return 0;
}
Now given a pFile named "cloak.tga" (which BTW, was opened succesfully),
this code will successfully load "cloak.tga" most of the time. However, at
an arbitrary point ( say the 4th or 5th time I call this code) fread will
fail. Once it fails it enters the above loop to try freading 9 more times.
Once it fails the first time it will ALWAYS fail the next 9 times. At this
point, when
delete [] pImageTemp;
is called, I get the following error message:
HEAP[Bruteball.exe]: Heap block at 070ADB18 modified at 070ADF50
past requested size of 430
So am I running out of Heap space? If so, why isn't new returning NULL?
Anyone have any ideas of how to fix this issue?
Thanks,
-Pete