Java 8 String deduplication vs. String.intern() -


i reading feature in java 8 update 20 string deduplication (more info) not sure if makes string.intern() obsolete.

i know jvm feature needs g1 garbage collector, might not option many, assuming 1 using g1gc, is there difference/advantage/disadvantage of automatic deduplication done jvm vs manually having intern strings (one obvious 1 advantage of not having pollute code calls intern())?

this interesting considering oracle might make g1gc default gc in java 9

with feature, if have 1000 distinct string objects, same content "abc", jvm make them share same char[] internally. however, still have 1000 distinct string objects.

with intern(), have 1 string object. if memory saving concern, intern() better. it'll save space, gc time.

however, performance of intern() isn't great, last time heard. might better off having own string cache, using concurrenthashmap ... need benchmark make sure.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -