4 ms·
The blog post he links makes me wonder... Is AS3 garbage collector a compacting one? He wants to make his memory usage to be flat, not a saw shape, but if the G
by viraptor 17y ago
The blog post he links makes me wonder... Is AS3 garbage collector a compacting one? He wants to make his memory usage to be flat, not a saw shape, but if the GC is not compacting, I wouldn't expect that to make a difference. Especially that in most GC designs, by using object pools you'd be trading the time it takes to update free area lists for the time GC spends going through the tree (you've got more objects used on average, all referenced in a pool).
Am I missing something here?
- Confusion 17y agoFrom http://www.adobe.com/devnet/flashplayer/articles/garbage_collection.html http://www.adobe.com/devnet/flashplayer/articles/garbage_col... I gather that the GC isn't compacting, but I'm not at home in GC terminology, so perhaps it is, but they use another term for it.
- barrkel 17y agoI can only think that the GC has a bug. From [1], the GC is incremental, but I suspect it's not guaranteed to make forward progress, because it's not collecting large orphaned object graphs. Object pooling may or may not make sense depending on whether the GC is generational or not, and how large the graph of live objects normally is. In a non-generational GC, the whole object graph will need to be traced to free any garbage at all, which means that if your live set of objects is large - and hence expensive to trace - you'll want to minimize the number of allocations, and pool almost as much as possible, especially if the GC is non-incremental and users can perceive freezes during a GC. In a generational GC, cheap objects should not be pooled, but it may make sense to pool objects that are expensive to allocate or collect. For example, in .NET large objects like long arrays (over 40K bytes IIRC) are allocated in a special heap that's only collected with a full GC. Pooling those guys makes a lot of sense, because dropping them as garbage will force full GCs too often. I would expect most modern GCs to be compacting (and generational), to avoid fragmentation, the cost of keeping track of a free list and improve locality, but if there's a lot of interop between the GC managed memory and native code, then updating references may be problematic. [1] http://192.150.8.60/devnet/flashplayer/articles/garbage_collection.html http://192.150.8.60/devnet/flashplayer/articles/garbage_coll...
- chipsy 17y agoAVM2 is currently non-generational, so it benefits from pooling. This works out just fine for Flash games, since you generally want games to have a highly static data set anyway - otherwise performance is just all over the place. AVM2 also has the "Alchemy memory" since Flash 10 which adds a whole new option, independent of the GC, for tightening your space/time constraints: http://lab.polygonal.de/2010/03/15/memorymanager-revisited/ http://lab.polygonal.de/2010/03/15/memorymanager-revisited/