String字符串性能优化的几种方案(15)


根据打印的日志分析:没有使用intern情况下 , 执行时间为354ms , 占用内存为24229k;

使用intern的GC日志:

使用intern:1515[GC (System.gc()) [PSYoungGen: 613417K->1144K(2752512K)
613417K->1152K(2758656K) 0.0012530 secs
[Times: user=0.00 sys=0.00 real=0.00 secs
[Full GC (System.gc()) [PSYoungGen: 1144K->0K(2752512K)
[ParOldGen: 8K->965K(6144K)
1152K->965K(2758656K) [Metaspace: 3780K->3780K(1056768K)
0.0079962 secs
[Times: user=0.02 sys=0.00 real=0.01 secs
HeapPSYoungGen      total 2752512K used 15729K [0x0000000700000000 0x00000007c0000000 0x00000007c0000000)eden space 2359296K 0% used [0x00000007000000000x0000000700f5c4000x0000000790000000)from space 393216K 0% used [0x00000007900000000x00000007900000000x00000007a8000000)to   space 393216K 0% used [0x00000007a80000000x00000007a80000000x00000007c0000000)ParOldGen       total 6144K used 965K [0x0000000640000000 0x0000000640600000 0x0000000700000000)object space 6144K 15% used [0x00000006400000000x00000006400f17400x0000000640600000)Metaspace       used 3786K capacity 4540K committed 4864K reserved 1056768Kclass space    used 420K capacity 428K committed 512K reserved 1048576K

推荐阅读