Is there a memory-efficient replacement of java.lang.String?

后端 未结 15 671
被撕碎了的回忆
被撕碎了的回忆 2020-11-30 19:29

After reading this old article measuring the memory consumption of several object types, I was amazed to see how much memory Strings use in Java:



        
15条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 20:11

    I believe that Strings are less memory intensive for some time now, because the Java engineers have implemented the flyweight design pattern to share as much as possible. In fact Strings that have the same value point to the very same object in memory I believe.

提交回复
热议问题