3 ms·
> reuse objects Caching is often not such a bad idea regardless of GC.
by Koshkin 5y ago
> reuse objects
Caching is often not such a bad idea regardless of GC.
- mikepurvis 5y agoFair, but I think some GC'd languages (Java, JS) end up with a culture of boxed-everything where it's extremely easy to inadvertently throw off a ton of garbage from an inner loop, even doing operations that in other languages would only ever instantiate objects on the stack.
- tadfisher 5y agoNewer Java runtimes are very conscious of tight garbage creation loops, and will generally either unbox or perform some internal object pooling to avoid GC pressure. Value types (targeting JDK 18? or maybe already in 17) will give developers a tool to create new stack-allocated types for performance-critical sections as well