418 words on earthlingsoft
It’s always a bad sign when you offer an update for one of your applications within a few days of the previous release. But, alas, that’s just what’s happening for Earth Addresser today to fix a memory problem which people with many addresses in their Address Book started to run into.
More technically, the problem was that I do create the necessary NSAutoreleasePool
in the thread that looks up the addresses to make sure no objects are leaked. But I underestimated the amount of memory that gets autoreleased by running the web download. As I never noticed any memory related problems myself - not even unexpected swapping - I never gave much thought to that, having in mind that each download I do only retrieves a very small file and even with the string processing I do before and after it, only a few kilobytes of RAM should be needed.
But I didn’t have in mind that doing the download may cause many other things to happen. One of them apparently being that a few megabytes of my (virtual) address space get eaten by each download. And I only recover those once my autorelease pool is released - after my loop has finished running, that is. Which means that after a small four digit number of address lookups Earth Addresser would hit the virtual memory ceiling and give a nice crash somewhere in Apple’s code (it appears that gracefully handling a lack of memory remains out of vogue even in the basic libraries).
Had the original bug reporter not pointed out that he observed high memory usage, I’m not sure I could have made sense of the crash reports, but with this in mind, creating a new autorelease pool for each iteration of my lookup loop was an easy way to solve the problem. Phew.
Another issue that cropped up - and which I fail to understand - is the following: Currently Earth Addresser is available in French for everything but the readme. My understanding of Cocoa’s localised resource loading is that in this case the code
NSWorkspace * WORKSPACE = [NSWorkspace sharedWorkspace]; [WORKSPACE openFile:[[NSBundle mainBundle] pathForResource:@"readme" ofType:@"html"]];
should open the readme.html file in the next best language as the French version is not available. But somehow it doesn’t do anything as the path returned by the NSBundle is nil
. Am I misunderstanding anything there? And how can I deal with such situations without needing to put a copy of the English file into the French localisation?