Path: utzoo!mnetor!uunet!husc6!bbn!mit-eddie!uw-beaver!cornell!batcomputer!eacj From: eacj@batcomputer.tn.cornell.edu (Julian Vrieslander) Newsgroups: comp.sys.mac.programmer Subject: How do you count unused master pointers? Message-ID: <4362@batcomputer.tn.cornell.edu> Date: 10 Apr 88 05:36:27 GMT Reply-To: eacj@tcgould.tn.cornell.edu (Julian Vrieslander) Organization: Cornell Theory Center, Cornell University, Ithaca NY Lines: 24 Keywords: master pointers The "standard" approach to allocating master pointer blocks is to (empirically) determine the largest number of handles an application is likely to need, and then to place enough calls of MoreMasters() in the initialization code to cover that worst case. A more sophisticated approach that I have seen described in a couple of places (including Scott Knaster's first book) involves periodically counting the number of unused master pointers. When you see them running low you call MoreMasters() again, making sure to do the call when it will not cause fragmentation (eg. from the event loop, with all segments unlocked). That sounds like a good idea, but I am not sure how to do it in a way that will not be broken by future changes to the master pointer format. Inside Mac says that the unused master pointers are kept in a linked list, and the address of the first one can be found in the heap zone header. But the master pointers themselves are not normal pointers - the high byte is used for flags, the low 3 bytes for the address. So it seems that special code is needed to traverse the list. Can this be done in a way that won't fail if the master pointer format changes? And how likely is it that the format will change? -- Julian Vrieslander (607)255-3594 Neurobiology & Behavior, W250 Mudd Hall, Cornell University, Ithaca NY 14853 UUCP: {cmcl2,decvax,rochester,uw-beaver,ihnp4}!cornell!batcomputer!eacj INTERNET: eacj@tcgould.tn.cornell.edu BITNET: eacj@CRNLTHRY