Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Automatic Breakpoint ; std::bad_alloc

Author
Message
LSM
13
Years of Service
User Offline
Joined: 30th Aug 2011
Location: Sweden
Posted: 30th Aug 2011 19:44
Hi,
I'm learning how to program with GDK and im making a basic FPS.
As i fouled around i got into a problem I can't load the weapon.

Heres the code of which I got right now. the problem lies within loadWeapond() and is with dbLoadObject...
Error I get is: (Automatic Breakpoint) First-chance exception at 0x75deb9bc in FPS-Game.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x003ffa90..

Unhandled exception at 0x75deb9bc in FPS-Game.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x003ffa90..
Code

Now I have No idea what this means but I hope someone of you do.

Regards,
Thomas
LSM
13
Years of Service
User Offline
Joined: 30th Aug 2011
Location: Sweden
Posted: 31st Aug 2011 21:34
Nvm I found my problem. Set the function within the loop...
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 31st Aug 2011 22:03
std::bad_alloc means that some function (dbLoadObject in this case) is trying to allocate memory and it can't get enough. But it's kind of strange that you load two dbo models and run out of memory... they can't be that huge (how big are they, actually?). Can it be that the object model itself is somehow corrupt so the system believes it's huge? Can you load that dbo file in another, smaller test program which does absolutely nothing else than load the weapon model?
LSM
13
Years of Service
User Offline
Joined: 30th Aug 2011
Location: Sweden
Posted: 2nd Sep 2011 21:58
Actually I was loading the same object numerus times... I had the function within the while loop and therefor making multiple objects... Now I solved it by moving the call handler for the function to outside the while loop (loading it once).

Regards,
Thomas

Come from PHP and VB 6.0, VBA Thought I would give it a try...
Now im a good programmer just not that good with math
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 3rd Sep 2011 13:40
I thought about that too, but in the code you showed, there seemed to be a boolean variable to prevent multiple loading, so I didn't mention it... anyway, good that you fixed it.
LSM
13
Years of Service
User Offline
Joined: 30th Aug 2011
Location: Sweden
Posted: 4th Sep 2011 02:00
Yes I thought I should have been fixed with an boolean but it might not have been loaded correctly when inside the loop... Wierd and fixed by moving it outside

Come from PHP and VB 6.0, VBA Thought I would give it a try...
Now im a good programmer just not that good with math

Login to post a reply

Server time is: 2024-10-02 19:20:20
Your offset time is: 2024-10-02 19:20:20