Newsgroups: comp.sys.mac.programmer Path: utzoo!utgpu!cunews!bnrgate!bmers95!bmerh563!slang From: slang@bmerh563.bnr.ca (Steven Langlois) Subject: Large Programs and Memory Management Questions Message-ID: <1991Apr24.122618.13791@bmers95.bnr.ca> Sender: usenet@bmers95.bnr.ca Organization: Bell-Northern Research Ltd. Date: Wed, 24 Apr 91 12:26:18 GMT I have some questions about memory management with large applications. Unfortunately, most sample code from any source is not nearly large enough to encounter memory management issues. The application I have been working on for some time now is approaching 375K. I have set the SIZE resource to specify an application memory size of 512K. Far too much of the available 512K is used up by code segments. Now I know about UnloadSeg and intend to use it but this is where my questions come into play. What is the best method for unloading segments? There is the "unload all your segments every time through your event loop" method but is this an effective method or are there other better methods? From what I have read, it is typically a good idea to unload your initialization segment before entering your main event loop. You will then not have to unload the this segment again because you know that you will never call the initialization code again. After doing this should you compact the heap or wait until a call to the memory manager does it for you? Should your application periodically compact the heap to keep it from getting fragmented? If so, when is a good time, maybe after the user executes a menu command? For those knowledgeable in THINK Pascal, is it a good item to load and lock the runtime environment or should you allow it to be unloaded like any other segment? What would happen if there was not enough memory to load a CODE segment? Would the program crash or just not call the routine in the segment? And more importantly, how do you prevent this from happening, especially when calling the routine may cause a chain of segments to be loaded? Well, I guess that will do for now. Any help would be greatly appreciated. Steven Langlois ISDN Basic Rate Access BNR, a subsidiary of Northern Telecom Bitnet: slang@bnr.ca Bitnet from AppleLink: slang@bnr.ca@DASNET#