I am having a problem with creating 10 million objects from a csv file on import in my application. Doing a heap dump I figured the Out-Of-Memory occurres when reaching around 4.8 million objects.
Researching a solution and looking into how to improve the GC I stumbled upon the VMOption:
-XX:+UseStringDeduplication
Using this I was able to create 7.8 million objects before Out-Of-Memory occurred, which is an increase of more than 60 %. The heap dump showed, that the strings and the byte[] in the heap where decrease by up to 75 %.
In another stackoverflow answer someone showed similar results in memory usage optimization. https://stackoverflow.com/a/27953779/10020419
So I am asking myself, why this isn't standard (I am using Java 11)?
The only downsides I read are more like smaller increasing of CPU, because the GC has to work a little more.
Are there any other reasons to not use this as a default?