On Jun 25, 2009, at 3:14 PM, Peter Ammon wrote:
In any case, it's been my experience that GC makes memory management much easier, but precious resource management somewhat harder. It's harder because GC forces more of a divorce between the management of memory and precious resources, and the precious resource management techniques are about on the level with C circa 1989.
Really, retain/release requires such a separation, too. At least, it does for relatively complex, often concurrent, piles of code.
I'll speak anecdotally instead of making broad claims. I have had to track down and fix more than a dozen bugs over the years that have all boiled down to exhaustion of some scarce resource such as a file descriptor, server connection or the like.
While the cause was sometimes simply a leak, it has often been caused by unexpectedly long delays until the autorelease pool was drained.
Even with leaks, a small leak is something that should be fixed, but is also something that you can live with for a while -- leaking 300 allocation nodes of 48 bytes each, say, every time a document is closed is only 14k per document and, thus, the user is gonna have to open/close an awful lot of documents to cause a problem.
However, if even a subset of those 300 nodes also contains some scarce resource, what is a minor problem will then be a major, possibly catastrophic, problem.
As well, if there are any kind of ordering dependencies when tearing down stuff, your code's fragility will be greatly reduced by moving the dependencies outside of memory reclamation. Otherwise, one stray - autorelease will cause the house of cards to crumble.
b.bum _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
