yahnke@vms.macc.wisc.edu (Ross Yahnke, MACC) (01/06/89)
application I'm writing I always check MemError() after each NewHandle call to see if there were allocation problems; when the application heap gets low, NewHandle should fail, MemError will tell me so, and I exit out gracefully. But in one case this doesn't work. I'm allocating mem for an offscreen image for each window I open, about 50K a shot. After a couple of windows, there's little heap left, TMON tell me there's just a few hundred bytes. I do another new window and consequently a HewHandle. Now, NewHandle should fail, right? And set MemErr to nonzero... but instead it just bombs, NewHandle never returns. When I start my program I init the SetGrowZone() thingy so as to call SysErr(25), and when I'm not running TMON, I get the standard error bomb dialog. Thus I suspect my Mac is having serious problems allocating memory...but NewHandle shouldn't just crap out, should it? Will it only fail gracefully if there's a lot of memory left but not as much as requested? I'm using LSC 3.0, w/Sys 6.0.2 running under MultiFinder w/2 1/2 megs, on a Mac+. Any comments would be appreciated. --muchos gracias //////////////////////////////////////////////////////////// Internet: yahnke@vms.macc.wisc.edu Bitnet: yahnke@wiscmacc(.bitnet) UUCP: {backbone}!uwvax!vms.macc.wis.edu!yahnke ////////////////////////////////////////////////////////////
tim@hoptoad.uucp (Tim Maroney) (01/06/89)
In article <1061@dogie.edu> yahnke@vms.macc.wisc.edu (Ross Yahnke, MACC) writes: >After a couple of windows, there's little heap left, TMON >tell me there's just a few hundred bytes. I do another new >window and consequently a HewHandle. Now, NewHandle should >fail, right? And set MemErr to nonzero... but instead it >just bombs, NewHandle never returns. When I start my program >I init the SetGrowZone() thingy so as to call SysErr(25), >and when I'm not running TMON, I get the standard error bomb >dialog. You neglected to say so, but I expect the bomb you get is with error 25, correct? When the memory manager can't allocate a pointer or handle by crook, it tries to do it by hook, that is, by calling your grow zone routine. Only if this also fails will NewHandle return zero and MemError tell you you are out of storage. You've set it up so that the grow zone routine bombs the system with a "SysError(25);" when it's called, so if you try to allocate storage that isn't there, you'll bomb before Newhandle or NewPtr ever returns. Solution: don't set up a grow zone routine, you're shooting yourself in the foot. "We want memory...memory...memory..." "You won't get it!" "By hook or by crook, we will!" "I am not a pointer, I am a free block!" "Ha ha ha ha ha!" (from THE POINTER, the 1960's cult TV show with Patrick McCheese.) -- Tim Maroney, Consultant, Eclectic Software, sun!hoptoad!tim "I am of the opinion that my life belongs to the whole community, and as long as I live it is my privilege to do for it whatever I can." -- Shaw