Copyright 2004 by M. Uli Kusterer Tue, 30 Dec 1969 07:58:58 GMT Comments on article blog-garbage-collection-work-of-the-devil at Zathras.de http://www.zathras.de/angelweb/blog-garbage-collection-work-of-the-devil.htm blog-garbage-collection-work-of-the-devil Comments witness_dot_of_dot_teachtext_at_gmx_dot_net (M. Uli Kusterer) witness_dot_of_dot_teachtext_at_gmx_dot_net (M. Uli Kusterer) en-us Comment 3 by bbum http://www.zathras.de/angelweb/blog-garbage-collection-work-of-the-devil.htm#comment3 http://www.zathras.de/angelweb/blog-garbage-collection-work-of-the-devil.htm#comment3 bbum writes:
# If you're churning through a lot of large objects in a loop,
# for example, it seems like the garbage collector can easily
# need a second to catch up which may just unnecessarily add
# 100MB or so to your memory consumption. Which seems fairly
# unnecessary.

First, the collector has improved over time. It is much more difficult to outrun the collector in Snow Leopard than Leopard and you can expect the trend to continue. In the rare case that you are allocating and deallocating a ton of memory, it is often the case that optimizing for reuse is the right answer, GC or non- (thrashing the heap with a ton of malloc/free events is painful regardless of memory management system used).

And that is really the crux of it; by offloading memory management to the system, you give the system to optimally manage memory resources, well, systemically. This includes automatically reaping the benefits of performance optimizations that happen over time. For example, in Snow Leopard there are a handful of patterns that are actually quite a bit faster under GC than non. Expect *that* trend to continue, too, and those apps that are GC'd to get that much faster along with it.
Comment 2 by ssp http://www.zathras.de/angelweb/blog-garbage-collection-work-of-the-devil.htm#comment2 http://www.zathras.de/angelweb/blog-garbage-collection-work-of-the-devil.htm#comment2 ssp writes:
I couldn't agreee more on the benefits of garbage collection. Anything that makes standard tasks easier and less error prone is great.

Yet, I didn't quite understand why using obj-c 2 garbage collection seems to completely remove manual memory management. If you're churning through a lot of large objects in a loop, for example, it seems like the garbage collector can easily need a second to catch up which may just unnecessarily add 100MB or so to your memory consumption. Which seems fairly unnecessary.

I assume doing things this way simplified the background magic, but I still wonder how people handle such situations when using GC.
Comment 1 by Jens Ayton http://www.zathras.de/angelweb/blog-garbage-collection-work-of-the-devil.htm#comment1 http://www.zathras.de/angelweb/blog-garbage-collection-work-of-the-devil.htm#comment1 Jens Ayton writes:
Wot, no context? :-) http://lists.apple.com/archives/objc-language/2009/Dec/msg00054.html