如何避免GenerateSerializationConstructorAccessor问题?
我们有一个接收 SOAP 请求的 Java 应用程序,在收到大量请求后,我们注意到 GC 停止了卸载大量的 generatedSerializationConstructorAccessor 类。这是一个很大的性能影响。
有谁知道如何避免这种情况或至少显着减少创建的GenerateSerializationConstructorAccessor类的数量?
We have a Java App that receives SOAP requests, and after a lot of requests we notice that the GC stops the world to unload a lot of GeneratedSerializationConstructorAccessor classes. This is a big performance impact.
Does anyone know how to avoid this or at least significantly reduce the count of GeneratedSerializationConstructorAccessor classes created?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您的应用程序使用反射,这是不可避免的,您可以尝试使用 CMS 垃圾收集器,以尽量减少 stop-the-world GC 的影响。
As it is impossible to avoid if your application is using reflection, you may try using CMS garbage collector to minimize the impact of the stop-the-world GC.
来自 http://coding.derkeiler .com/Archive/Java/comp.lang.java.programmer/2006-11/msg00122.html
看来它们只是暂时用于序列化/反序列化给定类的对象。正如文章指出的,这些可能是使用 SoftReferences 保存的,因此请确保您的应用程序有足够的内存,并且这些内存的回收频率会降低。
令人惊讶的是,似乎没有任何其他解决方案。
From http://coding.derkeiler.com/Archive/Java/comp.lang.java.programmer/2006-11/msg00122.html
It appears they're only used transiently to serialize/deserialize a given class of object. As the article points out, these are probably held using SoftReferences, so ensure that your app has plenty of memory, and these will be reclaimed less often.
Surprisingly, there doesn't appear to be any other solution.
使用以下选项之一:
在本机访问器“膨胀”为生成的访问器之前,增加通过构造函数/方法/字段的调用次数。默认值为 15。
完全禁用通货膨胀。有趣的是,这个选项似乎不会影响构造函数,但它确实适用于方法。
您可以使用简单的测试应用程序来测试这些选项:
编辑 (2013 年 12 月 29 日):
-Dsun.reflect.noInflation=true
选项禁用通货膨胀机制,取而代之的是立即使用生成的访问器,因此您不需要该选项。Use one of the options:
Increases the number of calls through a Constructor/Method/Field before a native accessor will be "inflated" to a generated accessor. The default is 15.
Disables inflation altogether. Interestingly, this option does not seem to affect constructors, but it does work for methods.
You can test the options with a simple test app:
Edit (29-Dec-2013): The
-Dsun.reflect.noInflation=true
option disables the inflation mechanism and instead immediately uses generated accessors, so you don't want that option.