Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker.mit.edu!mit-eddie!bbn.com!nic!chaos.cs.brandeis.edu!chaos.cs.brandeis.edu!phils From: phils@chaos.cs.brandeis.edu (Phil Shapiro) Newsgroups: comp.sys.mac.programmer Subject: Re: Another THINK Pascal gotcha - "With" instance vars Message-ID: Date: 11 Feb 91 21:38:51 GMT References: <1.27ACFB10@mmug.edgar.mn.org> <1991Feb6.060512.12890@uniwa.uwa.oz> Sender: @chaos.cs.brandeis.edu Organization: Symantec Corp. Lines: 36 In-Reply-To: andreww@uniwa.uwa.oz's message of 6 Feb 91 06:05:12 GMT In article <1991Feb6.060512.12890@uniwa.uwa.oz> andreww@uniwa.uwa.oz (John West (stealing Andrew's account)) writes: [ discussion of HLock'ing during "WITH myHandle^^" ] What happens if some program running in the background chooses that moment to do some memory shuffling? Goodbye handle. Remember John's three rules of Mac programming - 1) Always set your grafports 2) Always lock your handles 3) Buy a decent keyboard Please don't spread myths! Handles don't move unless the Memory Manager pushes them. As a Mac programmer, you're promised by the Memory Manager that this shuffling only occurs at certain times. What *does* happen if some program running in the background chooses some random moment to shuffle the heap? This shuffling will only occur in that application's heap, not your own. Besides, here's what Tech Note #180 has to say about context switching: "For conceptual clarity, it is best to think of MultiFinder 6.0 and earlier as using three types of switching: major, minor, and update. All switching occurs at a well defined times, namely, when a call is made to either _WaitNextEvent, _GetNextEvent, or _EventAvail." So, if your application expects memory to move during those three traps, then you should be OK under MultiFinder. -phil -- Phil Shapiro Technical Support Analyst Language Products Group Symantec Corporation Internet: phils@chaos.cs.brandeis.edu