Skip to main content
GameDev.net gamedev.net
🔒 Locked

Memory Manager woes

Started by Baraclese Jul 4, 2004 at 1:40 PM 2 replies 950+ views
Original Post
Baraclese
Baraclese
Hi, I just tested my own "game purpose" Memory Manager and it seems to work fine until I try to make a call to QueryPerformanceFrequency(). GetLastError() shows the error code 998 which means "Invalid access to memory location". This all happens after about 115 allocations and a few deallocs which includes initializing FMOD, FreeType, OpenGL and creating the window without problems. I remember having this problem when I started writing the manager the problem sometimes just appeared and disappeared again after making a few changes. But now I don't see anymore obvious bugs in my code which is about 1000 lines of pointer intensive code and I'm doing block coalescing, etc. just all the good stuff a real memory manager is supposed to do :) Do you have any tips for me about how to find out what's going wrong here? Baraclese
ApochPiQ
ApochPiQ
If you're compiling in debug mode, switch to release and see what happens; otherwise, switch back to debug. Also be sure you're recompiling all of your code fresh - delete all the .obj files and other intermediaries in between compiles. If you get mismatched code, especially in a system with a memory manager, all manner of strange things can happen. Other than that, set up some extensive logging and look for anything suspicious.
Baraclese
Baraclese
Yeah I'm doing pretty extensive logging here, I'm logging a complete trace through all used and free memory blocks and I log the state of all "bins" in which free blocks reside and everything looks normal. QueryPerformanceFrequency allocates 18 bytes (aligned to 24 bytes) and the memory does get allocated for it. There's no conflict with old object files.

Hm, I just remembered the problem used to appear and disappear when I was trying different hash functions to hash the memory addresses of occupied blocks. I don't know how that could affect QPF but I'll look into that.

Baraclese
Baraclese
Baraclese
oops I was messing this up, QPF doesn't allocate anything. That was already my throw code taking over =)
Anyway I'm initializing my timer in the constructor via QPF. My Win32 timer class inherits from an ITimer interface which includes the uint64 timer_resolution variable. My code looks like this:
Timer::Timer(){if ( !QueryPerformanceFrequency( reinterpret_cast<LARGE_INTEGER*>(&timer_resolution) ) ){	throw ();}}

If i call QPF from anywhere else in my code it will work but not here in the constructor although the memory for the Timer object gets allocated.
Any ideas?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.