Jump to content
  • Advertisement
Sign in to follow this  
ControlDenied

Strange error in allocation with new operator

This topic is 5409 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have a little struct QSort
struct QSort
{
	sID    ID;
	double SimilarityValue;
};

// sID is also another little struct

struct sID
{
	int m_ClassID;
	int m_ModelID;
};

and in a function I allocate memory with the command: QSort *Similarities = new QSort[Database.m_NumModels]; The program stops in this command and the problem is that (when debugging) it throws the following message: User breakpoint called from code at 0x77f6f570 It then shows the dissasembly window and when I proceed step by step, it requires the path for DBGHOOK.C which I cannot find anywhere. If I run the program it throws an unhandled exception in DBGHEAP.C at this point _ASSERTE(_CrtIsValidHeapPointer(pUserData)); Database.m_NumModels is an integer which I have ensured while debugging that has the right value. Does anybody know any possible reason for this to happen? I cannot think anything, everything seems to me correct. Thanks for any help!

Share this post


Link to post
Share on other sites
Advertisement
My guess is that something you've done before this point, but very recently before it, most likely, has corrupted the heap in some way or another. Check the code that runs before this line carefully. Look for deletes that might be deleting improper pointers, check for writing beyond the bounds of memory, make sure that you use delete [] when deleting arrays, etc.

Share this post


Link to post
Share on other sites
Ok, that seems realy strange and I am not shure, but I would try a constant instead of Database.m_NumModels.
If that works, then Database is perhaps not instanciated when refering to Database.m_NumModels.

Check all your Pointers if they are refering to an instanciated object when needed, because _ASSERTE(_CrtIsValidHeapPointer(pUserData));
seems to have a problem with pUserData (because _CrtIsValidHeapPointer() retruns false).

You will find it sooner or later, good luck :)

-Constantin

Share this post


Link to post
Share on other sites
I've just found it, I tried a whole day before posting in the forum and as usually it was something really silly, I deleted somewhere memory and used the array without reallocating

Thanks anyway for the interest!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!