Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!ksand From: ksand@Apple.COM (Kent Sandvik) Newsgroups: comp.sys.mac.programmer Subject: Re: How do you use HeapScramble? Keywords: hs heapscramble macsbug Message-ID: <47905@apple.Apple.COM> Date: 9 Jan 91 18:09:42 GMT References: <127599@linus.mitre.org> Organization: Apple Computer Inc., Cupertino, CA Lines: 32 In article <127599@linus.mitre.org> laf@mbunix.mitre.org (Lee Fyock) writes: >How do you use Macbugs' heapscramble ("hs")? I was running a THINK C project, >ran it to get to the debugger, dropped into macsbug, turned on heapscramble, >came back to the debugger and stepped on the line >InitGraf(&thePort); >whereupon I was dropped back into macsbug with a message about macsbug causing >the error... >The program runs quite well; I was checking my locks and unlocks. How is >heapscramble intended to be used? When you turn heap scrambling on, all the *relocatable* memory blocks in the heap will be moved (if possible) as part of the Memory Manager compaction scheme. This happens with traps such as NewPtr, NewHandle, ReAllocHandle, SetPtrSize, or SetHandleSize. Now if the heap is checked just before the scrambling, and if the heap is currupted you drop down to MacsBug with an error message telling of this. In a way 'hs' is a tool to enforce the worst-case situation in the heap, because programs should not break during heap compaction. If you have problems, check for things like dereferenced handle problems, or any other invalid handle cases. Hope this helps. Kent Sandvik, MacDTS -- Kent Sandvik, Apple Computer Inc, Developer Technical Support NET:ksand@apple.com, AppleLink: KSAND DISCLAIMER: Private mumbo-jumbo Zippy++ says: "C++, anything less is BCPL..."