[comp.sys.mac.programmer] "Out of memory"

laf@mbunix.mitre.org (Lee Fyock) (09/18/90)

What causes the multifinder message "The application XXX
unexpectedly quit (out of memory)"?  I would think that a
memory request (NewPtr or NewHandle) would cause it, but
shouldn't they just return null, with the appropriate MemErr?

Thanks,

Lee Fyock
laf@mbunix.mitre.org
MITRE    Bedford, MA

stevec@Apple.COM (Steve Christensen) (09/19/90)

In article <120394@linus.mitre.org> laf@mbunix.mitre.org (Lee Fyock) writes:
>What causes the multifinder message "The application XXX
>unexpectedly quit (out of memory)"?  I would think that a
>memory request (NewPtr or NewHandle) would cause it, but
>shouldn't they just return null, with the appropriate MemErr?

This should only happen if somewhere within the OS or ToolBox there's a
request for memory (which it can't get), and it can't back out gracefully.
I can't remember if this could happen when a new segment needs to be loaded
(or if that would return a segment loader error), but that's the kind of case
where it could happen.  In that case, one routine tries to call another
routine in another segment, the segment can't be loaded, and the app can't
go anywhere from there so it dies.

If the app itself calls NewPtr or NewHandle, it would check for a nil pointer
or handle, or MemErr, so it wouldn't suffer this kind of death.

steve
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 whoami?     Steve Christensen
 snail:      Apple Computer, 20525 Mariani Ave, MS-81CS, Cupertino, CA  95014
 Internet:   stevec@goofy.apple.com
 AppleLink:  stevec
 CompuServe: 76174,1712

kurash@chocorua.dartmouth.edu (Mark Valence) (09/19/90)

In article <10287@goofy.Apple.COM> stevec@Apple.COM (Steve Christensen) writes:
>In article <120394@linus.mitre.org> laf@mbunix.mitre.org (Lee Fyock) writes:
>>What causes the multifinder message "The application XXX
>>unexpectedly quit (out of memory)"?  I would think that a
>>memory request (NewPtr or NewHandle) would cause it, but
>>shouldn't they just return null, with the appropriate MemErr?
>
>This should only happen if somewhere within the OS or ToolBox there's a
>request for memory (which it can't get), and it can't back out gracefully.
>I can't remember if this could happen when a new segment needs to be loaded
>(or if that would return a segment loader error), but that's the kind of case
>where it could happen.  In that case, one routine tries to call another
>routine in another segment, the segment can't be loaded, and the app can't
>go anywhere from there so it dies.
>
>If the app itself calls NewPtr or NewHandle, it would check for a nil pointer
>or handle, or MemErr, so it wouldn't suffer this kind of death.

Application XXX may not be the problem.  Since there is no memory protection
(that topic has been beaten to death already), any other program can write to
application XXX's memory (accidentally, of course).  Maybe you have an evil
INIT, or one of your other apps running under MultiFinder is giving you trouble.

Cut to the point!  The evil program might trash a master pointer block, or some
other important heap information, which would make XXX think that it ran out of
memory.  Some ROM routines like to have a FEW bytes of heap space when they run,
but MacEvilApp has made it look like you have no space (or even negative space).
Ooops.

Of course application XXX and MacEvilApp might be one in the same.

Mark.

cc100aa@prism.gatech.EDU (Ray Spalding) (09/20/90)

In article <120394@linus.mitre.org> laf@mbunix.mitre.org (Lee Fyock) writes:
>What causes the multifinder message "The application XXX
>unexpectedly quit (out of memory)"?  I would think that a
>memory request (NewPtr or NewHandle) would cause it, but
>shouldn't they just return null, with the appropriate MemErr?

You are correct, NewPtr/NewHandle don't cause this.  My experience has
been that you may get this when you call a system routine that expects
a good pointer or handle, and you pass in a nil.  The routines that
expect a RgnHandle seem particularly good at checking for this.
-- 
Ray Spalding, Technical Services, Office of Information Technology
Georgia Institute of Technology, Atlanta Georgia, 30332-0275
uucp:     ...!{allegra,amd,hplabs,ut-ngp}!gatech!prism!cc100aa
Internet: cc100aa@prism.gatech.edu

murat@farcomp.UUCP (Murat Konar) (09/20/90)

In article <120394@linus.mitre.org> laf@mbunix.mitre.org (Lee Fyock) writes:
>What causes the multifinder message "The application XXX
>unexpectedly quit (out of memory)"?  I would think that a
>memory request (NewPtr or NewHandle) would cause it, but
>shouldn't they just return null, with the appropriate MemErr?


I'm not certain, but perhaps this is what happens when a program 
tries to load in a code segment and fails due to lack of memory.



-- 
____________________________________________________________________
Have a day. :^|             
Murat N. Konar	
murat@farcomp.UUCP             -or-          farcomp!murat@apple.com