英文:
How to improve the performance of StringBuilder while constructing log cause it expands capacity?
问题
我在项目中使用Thrift作为RPC框架,它会自动生成使用StringBuilder的toString方法。但当对象太大时,通过火焰图我发现在多次扩展容量时,StringBuilder的性能开销很大。有没有什么方法可以优化这个问题?
英文:
I use thrift as a RPC framework in project which automatically generates toString method using StringBuilder. But when the object is too big, using flame graph I found StringBuilder cost a lot while expanding capacity too many times. Is there any ways I could optimize it?
专注分享java语言的经验与见解,让所有开发者获益!
评论