Creating a new object is never free, but it used to be far more expensive. To my knowledge the original Java GCs weren't compacting & had to find the best place in the heap to stick a new object. This required a linear search of the available free blocks. This is obviously much slower than incrementing a pointer at the edge of your used space. Unfortunately my search-fu has failed me & I can't find corroboration of my claim.
My impression of Java these days is to start with the "right" thing (allocate as needed, etc) and not to overly concern yourself with performance until it becomes an issue. There are certainly situations where allocating lots of objects (say billions or, maybe, millions) causes performance issues, but creating object pools to preemptively avoid that is a lot of extra work that may not be worth it.
My impression of Java these days is to start with the "right" thing (allocate as needed, etc) and not to overly concern yourself with performance until it becomes an issue. There are certainly situations where allocating lots of objects (say billions or, maybe, millions) causes performance issues, but creating object pools to preemptively avoid that is a lot of extra work that may not be worth it.