Archived

This topic is now archived and is closed to further replies.

yanuart

Weird problem with heap in XP

Recommended Posts

Hi, I wrote my program using Visual Studio 6 and on Win98. I used lots of new operator to allocate my object on heap and also to allocate a block of heap and use pointer/array that sorta thing, everything works just fine and I never had any problem using the new []/delete[] thingy but when I move my code to WinXP, everything is crash and burn, when I trace and debug it, sometimes my variables/member variables changed its value without any good reason. And sometimes I can''t even delete my object I''ve allready trace and debug it so that there are no mem. leaks and stuff, but the problem is still the same, and I''ve read that in WinNT(XP) it uses different dynamic heap managing method. Is it true ?? so how do you manage your heap in your program in WinXP ?? Is there a safe way (just simple compiler/linker options) to make sure that my heap allocation runs correctly ?? without making any modifications to your code ??

Share this post


Link to post
Share on other sites
Most of the time heap corruption results from design error and or misplaced code. I recommend rechecking every line and use breakpoints to walk through the lines before and after the program crashes.

Kuphryn

Share this post


Link to post
Share on other sites
Nope, it''s not a multi thread app..
What do you mean with buffer overrun prob. ??
Are you saying that when I use new/malloc/else it can allocate heap in a place that''s not safe ??

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
It''s not uncommom for programs with memory problems to work correctly sometimes on win95, win98, or winME. It''s because they are more lenient about errors. This is also part of the reason that programs and those versions of windows are less stable. Windows NT/XP is more rigorous about the use of memory. You probably have a memory allocation/deallocation error. Or you are probably corrupting memory somehow (array bounds error perhaps?)
At least this is what I''ve seen in my experience, perhaps your situation is unique.

Share this post


Link to post
Share on other sites
quote:
Original post by yanuart
Nope, it''s not a multi thread app..
What do you mean with buffer overrun prob. ??
Are you saying that when I use new/malloc/else it can allocate heap in a place that''s not safe ??


Buffer overrun is where you keep writing past the end of your array. Windows 2000/XP are more "strict" (for want of a better word) when it comes to memory and things like that. Each new release of Windows has extra checks on parameters you pass to functions and so on.

If I had my way, I''d have all of you shot!


codeka.com - Just click it.

Share this post


Link to post
Share on other sites