Now that I’ve finished reworking the Initialization routines, I should also make sure that the Finalization routines work right. The best way to do this is to look for memory leaks and plug them. Using the program Memory Sleuth, I can run Behold and identify where memory is allocated that is not released. Last time I did this and closed all the leaks was probably a year ago.
Just starting up Behold allocates about 300 KB of RAM. Without doing anything except immediately closing gives a memory leak of 60 bytes and 2 live pointers remaining. Memory Sleuth tells me that one leak is where I initialize my Families List but never free it. That was 16 bytes and 1 pointer fixed. The other 44 bytes was my Most Recently Used file list. Fixed.
Now do the same but load a GEDCOM first. It loads up to 2 MB in RAM. When I close it, no memory remains allocated. Excellent! Now try loading one GEDCOM and then adding another and them releasing. Whoops: 4380 bytes and 109 pointers remain. Looks like a job I can’t finish tonight.