Re: java8 up to 6x slower than java7
On 16.02.2014 14:43, Jan Burse wrote:
Jan Burse schrieb:
For the slower use cases I am planing using my custom
HashMap. The custom HashMap has some further advantages
besides sparing the iterator, I also don't do mod
counting.
Last but not least, one feature I am constantly missing
from HashMap, is that it should grow back in size.
HashMap is only growing and growing, and never
automatically shrinks.
Usually there is good reason to not do this: if a long lived collection
reaches a particular size at some point in time chances are that it will
do so in the future again. Shrinking will cause allocation overhead and
- at a later point - another allocation for the larger size which has
higher risk of causing slow GC because of memory fragmentation. Also,
if the long lived collection resizes internally at least for some GC
cycles there is a reference from old gen to new gen.
For short lived objects additional allocations to save memory are even
worse. There it's usually best to just grow.
For the long lived case you can still manually shrink by creating a new
collection if the nature of your application is such that there
temporarily the collection grows huge and afterwards shrinks again.
Kind regards
robert