ml10+@andrew.cmu.edu (Michael A. Libes) (12/04/89)
Can someone explain this problem? I am writing a small Multifinder "faceless" background program. My SIZE #-1 resource is set for 8192 bytes and all the flags are set to what is logical. Using MacsBugs, I checked the actual heap zone for the application. Somehow, my program was given an EXTRA 13900 bytes which it doesn't need or use. I tried unsetting the "Background Only" flag in the SIZE resource and ran the program. In this configuration, the program couldn't run, I got an "Out of Application Memory" error. After increasing the requested size to 15K, I ran it again. I put the SIZE resource back to background only and 8K and launched the program. Watching the "About the Finder" dialog, I notice that the Finder says that my program uses up 26K of memory. I only ask for 8K, I only need 8K?!? According to MacsBugs, my program is now getting 8628 bytes LESS than requested. I have subsequently looked at other programs. No program gets all the memory it requests. I assume some memory goes into Multifinder overhead, and some system overhead. Isn't something wrong here? If an application programmer figures that his program uses 50K, and he requests for 52K to be on the safe side, won't he be confused when his program runs out of memory? If you have any idea why this happens, please post so that everyone will learn of this Multifinder "feature." -Lunarmobiscuit (ml10@andrew.cmu.edu)
goldman@apple.com (Phil Goldman) (12/04/89)
In article <8ZSMKFS00Uh7M1D0su@andrew.cmu.edu> ml10+@andrew.cmu.edu (Michael A. Libes) writes: > Can someone explain this problem? > I am writing a small Multifinder "faceless" background program. My > SIZE #-1 resource is set for 8192 bytes and all the flags are set to > what is logical. Using MacsBugs, I checked the actual heap zone for the > application. Somehow, my program was given an EXTRA 13900 bytes which > it doesn't need or use. This must have occurred on a Mac II. The default stack size on a Mac II is 24k, whereas it is only 8k on a Plus or SE. The stack is larger because the system (especially QD) needs it. Therefore, MF "normalizes" the memory given to an app (by adding <deflt stack size> - 8k) so that the amount free to the app is the same on all machines. Now, MF only does this for a non-faceless apps. In fact, I believe that if you make your app faceless, it will use even less than 8k for the stack - closer to around 6k I think. This is possible because the big stack users such as QD will never run off this stack, and it is machine-independent. > I tried unsetting the "Background Only" flag in > the SIZE resource and ran the program. In this configuration, the > program couldn't run, I got an "Out of Application Memory" error. After > increasing the requested size to 15K, I ran it again. Even with only a 6k stack if you make your app size a mere 8k then the heap and jump table and globals will only have 2k to share. Probably you will need a total of 14k minimum in your SIZE resource to run. > I put the SIZE resource back to background only and 8K and launched > the program. Watching the "About the Finder" dialog, I notice that the > Finder says that my program uses up 26K of memory. You must not have, because if you had the backgroundOnly flag set then the Finder would not have displayed your app in the About Box anyway. > I have subsequently looked at other programs. No program gets all > the memory it requests. They should all get more than requested. > I assume some memory goes into Multifinder > overhead, and some system overhead. MF is very good about taking little or no space in the app heap. However, given that MF needs some extra amount of memory somebody will be confused about where it goes. For example, if it does not come out of the app heap then users will be confused when they launch a 8k program and the amount free drops by 14k. The only way to make this explicitly clear is to add a "system overhead per app" item to the About Box. This is definitely sub-optimal. -Phil Goldman Apple Computer