在Java中使用弱引用的代价 [英] Cost of using weak references in Java
问题描述
有没有人研究过在创建和垃圾收集Java中涉及的运行时成本? WeakReference 对象?对于多线程应用程序是否存在任何性能问题(例如争用)?编辑:显然,实际答案将取决于JVM,但一般观察也是受欢迎的。编辑2:如果有人已经做了一些性能基准测试,或者可以指出一些基准测试结果,那将是理想的。 (抱歉,但赏金已过期...)
WeakReferences对CMS垃圾收集器有负面影响。就我从服务器的行为中可以看出,它影响并行备注阶段时间。在此阶段,所有应用程序线程都会停止,因此这是非常不可取的事情。所以你需要小心WeakReferences。
Has anyone researched the runtime costs involved in creating and garbage collecting Java WeakReference objects? Are there any performance issues (e.g. contention) for multi-threaded applications?
EDIT: Obviously the actual answer(s) will be JVM dependent, but general observations are also welcome.
EDIT 2: If anyone has done some benchmarking of the performance, or can point to some benchmarking results, that would be ideal. (Sorry, but the bounty has expired ...)
WeakReferences have negative impact on CMS garbage collector. As far as I can see from behavior of our server it influences parallel remark phase time. During this phase all app threads are stopped so it's extremely undesirable thing. So you need to be careful with WeakReferences.
这篇关于在Java中使用弱引用的代价的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!