Garbage collection behaviour for String.intern()

前端 未结 4 1625
北恋
北恋 2020-11-27 07:31

If I use String.intern() to improve performance as I can use \"==\" to compare interned string, will I run into garbage collection issues? How does the garbage collection me

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 07:43

    Please read: http://satukubik.com/2009/01/06/java-tips-memory-optimization-for-string/

    The conclusion I can get from your information is: You interned too many String. If you really need to intern so many String for performance optimization, increase the perm gen memory, but if I were you, I will check first if I really need so many interned String.

提交回复
热议问题