[quote]Where we’ve had to deal with silly amounts of object creation and GC is in Sun’s own libraries in java.util. HashSet and HashMap are particularly troublesome as every time you make a query to the classes you create a new Entry instance. As we’re making thousands of calls to the HashSet/Map classes per frame (for various reasons), this was causing large amounts of stuttering in the frame rate due to GC.
[/quote]
What a weird decision. If i understood correctly, you got bothered by sun’s hashmap implementation, and instead of correcting that by doing your own implementation, you took the risk of settling on pooling? I guess that you also had to remove the hashmap calls, or do your own implementation… Well…Any decision can be justified and if this is what was done, i’d like to know why…
Pooling itself is easy, or it can be easy depending on how nice you want to play with the system. Implementing a nice pooling that takes care of memory problems can be more than 20 simple lines. If pooling is to you what CristalSquid just pasted, well, sure, it is easy. It is also very simplistic. Nevertheless, you forget the burden added on the projects or its subparts because of it. When you add pooling, you tend to change architecture to bend to implementation, which is definitly bad. Pooling never comes free.
But, as you said, people might not implement pooling correctly (even if in current case, it can hardly be wrong), which is one of the reasons it is ‘dangerous’ and why it should not be a commonly proposed solution. Recommending pooling to anyone that does not have complete and update knowledge of GC looks to me as recommending the opposite. It can also do more bad than good.
Nevertheless, i’m not saying your decision of pooling was bad. Personnally, i would not have done GoSub one year ago, as Generationnal GC was not as fine as now. I’d be curious to see how your old sources of the projects would run with current VMs and if pooling would still be necessary.
Anyway, the concept of pooling is now what is done by generationnal GC and the interest of doing double caching looks inexistent to me.