From: afry@troi.cc.rochester.edu (Alan R. Fry)
Newsgroups: comp.sys.mac.system
Subject: Urrrkkk! Finder heap is killing itself.
Summary: who messes with the finder heap?
Keywords: Finder, heap, FWB Hard Disk Toolkit, Silverlining, Swatch, Init Scope
Date: 17 Nov 92 18:25:31 GMT
Organization: University of Rochester (Rochester, NY)


I have a very pesky problem with the finder crashing.  I think it's a
problem with an extension, and I'll probably be able to fix it, but I would
really like to understand why the heck it is happening.

If you want to stop reading here but still give me a hand, you can tell me
if you know of any extensions that patch or trap routines in the Finder,
especially any having to do with heap management.  Braver souls may venture
further.  

Warning: this turned out to be pretty long and wordy, but I figured it would
be better to spell everything out than to have people write me back and ask
'Have you tried blahblahblah?' when blahblahblah was something I had done a
few dozen times.  :-)

Here's the rundown.

Hardware: SE/30, 8MB, 105MB HD, Micron Xceed 8-bit card, Sony 1304 monitor,
	  44MB Syquest drive

System:	  7.1, unmodified except for fonts and a few
	   fkeys.  Virgin Finder.  24 bit mode, no VM.  Usually running with
	  gobs of extensions (more on that later).  Same problem earlier
	  with System 7.0 and a modified finder (fast copy, no zoom rects).

Problem:  The finder heap fails to free up enough heap space to continue
	  running for any decent amount of time.  It just uses its free heap
	  space as it needs it, and then never frees it back up.  Eventually
	  when it is completely out of memory, I get one nice message "Sorry
	  out of memory.  Close some windows, etc., etc." and then a long
	  (longer than my patience for repeatedly hitting the OKAY button) 
	  string of very nasty messages proclaiming the dreaded Error -192
	  (Resource not found).

The Cause:  It is partially an init (extension) problem, because the Finder
	    can take care of itself if I start up with all extensions off
	    (using the trusty shift key).  This particular problem was also
	    preceeded by a change to the drivers on my HD, and a
	    non-recoverable BTree error that forced me to reformat and
	    replace my HD partition from backup.  But the strange thing is
	    that everything was 'just fine' with the same set of extensions
	    and the old HD drivers (system 7.0).  Now even if I switch back
	    to the old drivers, I still get this problem.

Things I Have Done:	Rebuilt the desktop, replaced the Finder, run
			DiskFirstAid, run Norton, replaced the HD drivers,
			reformatted the partition, restored from a backup,
			reinstated the old HD drivers, reinstalled the
			system, installed a fresh system, run a virus
			checker, removed suspicious extensions, ran amuck.

Things I Haven't Done:	Installed a fresh pre-system 7.1 system (because it
			isn't a sys 7.1 specific problem

Here is the sequence of events leading up to this whole mess:

I had been running with Silverlining 5.27 HD drivers and System 7.0 (tuneup,
of course) for quite a while, but I was always nervous because 5.27 is not
100% System 7 compatible.  So last week I side-graded to the FWB Hard Disk
Toolkit (HDT) and eagerly went to install it on my 105MB HD with 3
Silverlining partitions.  Well, the HDT drivers take up about 34K, and the
SL drivers only take up 16K, so I had to use SL to decrease the size of one
partition to make enough room for the HDT drivers to install.  No problem.
Then I used the HDT Primer to 'take over' each partition (something which I
don't exactly understand, despite the excellent HDT documentation) and make
them all automountable.  Still no problem.  I was converting my Syquest
cartridges over in the same way and doing some random file shuffling between
the HD and Syquest when I started getting the dreaded Finder errors (-192).

I just ignored them for a while, restarting and hoping it would 'go away'
(snicker) but then the Finder started behaving very badly.  Icons on my boot
partition disappeared, and many programs were behaving as if their
preferences were trashed (which, it turns out, they were).  I ran Norton
Disk Doctor on the partition, and it told me that I had a trashed BTree, and
there was nothing it could do about it.  I ran DiskFirstAid 7.1, and it told
me the same thing:  trashed BTree, out of luck.  I had a recent backup, but
just for the hell of it, I backed up the damaged partition on a different
cartridge, too.  Then I used HDT to completely erase the partition, and I
restored the damaged version that I had just backed up.  Everything on the
partition was fine, except that the Preferences file was completely missing
from the System Folder, so I restored that from my other backup.  

I rebooted, and I still got the Finder errors.  I tried replacing the Finder
with a clean copy, and I still got the errors.  I tried booting with no
extensions and I *think* I still got the errors (many hours of this were
grinding down my brain), so I thought it must be the new driver software.  I
used HDT to switch over to the SL drivers (which were still on the disk),
and booted with extensions on, and got the errors.  I switched back to the
HDT drivers, booted with extensions, and got the errors.  

It seemed like a corrupted System so I decided now would be a good time to
upgrade to System 7.1.  I installed 7.1 from disk images on a Syquest
cartridge using MountImage (which I know has been buggy, e.g. the Quicktime
1.5 image doesn't install correctly).  Reboot, still the errors.  Well,
maybe if the System was corrupted, the corrupted parts didn't get replaced,
so I copied out all my sounds (about 10) and fkeys (MountEm, Switch-a-Roo,
Window Reset, and some sound control thingy) and installed a pure System
7.1.  Reboot, errors.  Reboot with no extensions, no errors.  Go back to the
SL drivers, reboot, errors.  Reboot with no extensions, no errors.  Back to
the HDT drivers.

Somewhere along the line I started watching the Finder heap using a program
called Swatch by Joe Holt at Adobe (although it isn't an Adobe product).  It
shows a graph of how much free, used, and purgable heap you have in each
running process.  It is interesing that when the Finder is running
'normally' it almost never has more than 13K of free heap.  When you open a
lot of windows, 'get info' on a large folder, sort by name, etc., you use up
some of the free heap, but it usually doesn't go much below 3K.  Even if you
intentionally open dozens of windows the free heap only goes down to about
1.6K, and sometimes it even goes up (forgets about rear windows, I
presume).  When everything gets closed, the free heap rebounds back to 3.5K
or so.  You can use Swatch to compact the heap of a program (clear the
purgable heap, I presume), and in 'normal' Finder operation, doing this gets
you back up to about 12K of free heap.  When my Finder is running in
Reckless Self-Destruct mode, the amount of free heap just keeps getting
smaller and smaller as it is replaced by non-purgable heap.  The heap drops
down to less than 160 free bytes, and then WHACK, polite 'too many windows
open' message followed by -192 errors until I reset.

Well, like I said way back when, some extension is triggering this Finder
problem, and I'll eventually find it and tie it up and kill it, even if it's
one that I really love.  But I am very curious to find out how the problem
is coming about, and what triggered it in the first place.  I mean, things
were swell before I put in the new HD drivers, and now even the old drivers
don't seem to help.  Grrr....  

I have run an extension called Init Scope, by David P. Sumner, which monitors
the entire loading process during startup, so I have a list of patches and
installations for all of my extensions.  I'm not a programmer, so I don't
understand what the heck all (or any, really) of them mean, but it seems
that if any of them patch the heap management routines for the Finder or
actually use Finder heap (instead of System heap), there might be my
problem.  Maybe I have an extension that got corrupted when my BTree got
chopped down.  Do any of you clever programmers out there have any ideas
about which patches or low memory globals I should be looking for?

By the way, here is a list of most of my extensions.  Disinfectant,
IconWrap, OnStartup (part of OnCue II), AfterDark 2.0v, CEToolbox, Color
Arrow, DepthGauge, DiskDoubler INIT, DiskExpress II, DiskTop.Extras 1.01,
FileSaver (part of NU 2.0), Finder View, Finder Select, Just Click,
MasterJuggler, Memory (part of sys 7.1), MountImage, NowMenus, On Cue II,
PopChar, Programmer's Key, PwrSwitcher NC, QuicKeys 2, Radious MATH,
Remember? Extensions, SCSIProbe 3.4, Shutdown Delay, SmartKeys 2.1,
SpeedyFinder7, Super Boomerang, SuperClock!

I have removed the most suspicous extensions, such as SpeedyFinder7 and AD
2.0v (waiting for 2.0w).  Finder View and Finder Select sound suspcious, but
they don't do much (command key equivalents in the View menu and extended
rear-window select capabilities).  Nothing else leaps out at me.

Yikes, this has run on!  I'm going to sit down with a pot of coffee tonight
and carefully remove extensions and run through my little battery of tests
to see if the Finder heap will crash (it doesn't take very long).  If I work
it out, I will post something (short, I promise) about it.  In the meantime,
if anyone would like to share some advice or similar experiences, please
write or post (for god's sake, don't include the whole article!).

Alan
--
............................................................................
  Alan R Fry                        Find the hidden faces in this .sig     
  afry@troi.cc.rochester.edu        and you win a free straitjacket!       
............................................................................