Re:A Garbage Collector for C and C++
by Skinney on Friday July 10, 2015 @08:13AM
(#9863439)
True, but object pools enables you to reuse objects, which in turn allows you to avoid or postpone GC (if done correctly).
[ Parent
| on HN ]
Re:A Garbage Collector for C and C++
by chrisseaton on Friday July 10, 2015 @10:14AM
(#9864044)
But object pools prevent escape analysis and scalar replacement of objects, which wouldn't create garbage in the first place.
In theory, this sounds true. In practice, it isn't. I've done pooled versus non-pooled tests of objects like Vector3's in libgdx and the difference in memory pressure is fairly huge.
The JVM is really, really smart, but this is a well-understood area where you sometimes have to break the rules and do something stupid (and it is stupid) for the sake of perf.
Oh--and also consider that some of us (hi) aren't writing for HotSpot, yeah?
Re:A Garbage Collector for C and C++
by kasey_junk on Friday July 10, 2015 @11:15AM
(#9864383)
Particularly in concurrent contexts escape analysis offers you no help.