Path: utzoo!attcan!uunet!lll-winken!ames!oliveb!apple!rutgers!att!pegasus!ech From: ech@pegasus.ATT.COM (Edward C Horvath) Newsgroups: comp.sys.mac.programmer Subject: Re: Object Pascal and memory management Message-ID: <2642@pegasus.ATT.COM> Date: 1 Mar 89 02:22:51 GMT References: <532@Portia.Stanford.EDU> Organization: AT&T ISL Middletown NJ USA Lines: 32 From article <532@Portia.Stanford.EDU>, by rick@Jessica.stanford.edu (Rick Wong): > Calling UnloadSeg in Object Pascal may be tricky... Calling UnloadSeg is downright dangerous until you have a better understanding of how to segment your code. Read the MPW Linker description, paying particular attention to the "new segment" commands. Read the analogous parts of your pascal manual. Repeat as needed. Now organize your program into groups of related functions until all the groups are under 32K in size. Finally, VERY CAREFULLY introduce UnloadSeg calls so that nobody ever tries to UnloadSeg a segment FROM WHICH IT MIGHT BE CALLED. Scott Knaster recommends a simpler approach, namely at one place, at the top of your event loop, call UnloadSeg for every segment except CODE 1. Oh, yeah: make sure the event loop is in CODE 1! While this approach is nowhere near optimal, it's simple and hard to screw up. Doing a proper job requires that you truly understand the flow of your program. (Is there anything like 'cflow' in MPW?) If this sounds like a royal pain in the back of your lap, you're absolutely right. If you're writing a commercial application with rigid memory constraints you will have to do it anyway. Or hope that MacApp does it right for you, but MacApp is not the Philosopher's Stone: it can only deal properly with what it understands. But if you're doing a something less life-and-death, you can just break the code into segments wherever you please to get 'em all under 32K. If you like, mark all the CODE resources PreLoad with ResEdit, or use the Knaster hack. Repeat, I do NOT recommend this for anything which is going to ever see the light of day, and for ghod's sake don't put MY name on it, but when it doesn't matter why bother? =Ned Horvath=