Strange memory...

Started by
11 comments, last by Zoot 21 years, 8 months ago
HEAP[Demo.exe]: HEAP: Free Heap block 4c66250 modified at 4c66310 after it was freed Anyone know what it means? I only get this message when i load big maps in my engine.. it works perfectly with small maps.. I am useing new and delete...
GSACP: GameDev Society Against Crap PostingTo join: Put these lines in your signature and don't post crap!
Advertisement
Sounds like you are reading/writing through a pointer that has been free''d or delete''d.
Try setting your pointers to 0 / NULL after deletion, you''ll get a runtime access violation as soon as you try using the freed pointer.
"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
But it works with small maps..
GSACP: GameDev Society Against Crap PostingTo join: Put these lines in your signature and don't post crap!
But it works with small maps..
GSACP: GameDev Society Against Crap PostingTo join: Put these lines in your signature and don't post crap!
do what he said, it only works with small maps because u''re lucky or something. use a memory manager like MMGR (http://www.fluidstudios.com/publications.html) to make debugging memory leaks easier. if your program starts crashing often when u use it, that''s good, because it detected something bad, read the log files and fix it.

---
shurcool
wwdev
Maybe the problem doesn''t manifest itself with small maps... bugs can be weird and once they occur and the program goes into an undefined state, anything can happen! I would definitely recommend the nulling of the pointers after the delete, that should cause the program to die at the point where the freed pointer is dereferenced, if you run through the debugger you should be able to see the exact line that it happens on.

The only other thing I can think of is that you could be using a 16-bit compiler and you are trying to allocate more than 64K at once.

... thought of a few more possibles...

Have you checked that the allocations actually succeed? Does new throw an exception or return NULL if it fails?

I would certainly recommend running the code through a debugger and mabe putting breakpoints on every line that you call delete... to check everything is working as you expect.
"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
I tested the memory manger but it didn´t work so well with ifstream..

But i plaied some and now i get this error instead:

memory check error at 0x03ECBF10 = 0xF8, should be 0xFD.
memory check error at 0x03ECBF11 = 0xE4, should be 0xFD.
memory check error at 0x03ECBF12 = 0xA8, should be 0xFD.
memory check error at 0x03ECBF13 = 0x03, should be 0xFD.

[edited by - Zoot on August 14, 2002 2:44:52 PM]
GSACP: GameDev Society Against Crap PostingTo join: Put these lines in your signature and don't post crap!
It means you''re writing to memory you shouldn''t. Paradigm Shifter''s suggestions sound reasonable. Or maybe you are writing past the boundaries of an array.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]
quote:Original post by shurcool
do what he said, it only works with small maps because u're lucky or something. use a memory manager like MMGR (http://www.fluidstudios.com/publications.html) to make debugging memory leaks easier. if your program starts crashing often when u use it, that's good, because it detected something bad, read the log files and fix it.

---
shurcool
wwdev


Have any idea of how i can get it to work with ifstream?

This works but gives memory leaks:

ifstream *file = new ifstream(filename, ios::in );
file->close();

Any ideas?

[edited by - Zoot on August 14, 2002 9:53:26 PM]
GSACP: GameDev Society Against Crap PostingTo join: Put these lines in your signature and don't post crap!
Well, you''re not freeing the ifstream, are you? "delete file;".
But why bother allocating it like that? Why not just:

ifstream file(filename, ios::in);

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]

This topic is closed to new replies.

Advertisement