Java HTMLUNIT v. 2.15 Bug 线程死锁

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24259256/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 11:09:49  来源:igfitidea点击:

HTMLUNIT v. 2.15 Bug Thread deadlock

javamultithreadingdeadlockhtmlunit

提问by Azincourt

I'm using htmlunit (version 2.15); I noticed a memory leak issue with the WebClient class: all webClient instances are not cleaned by garbage collector.

我正在使用htmlunit(2.15 版);我注意到 WebClient 类存在内存泄漏问题:垃圾收集器不会清除所有 webClient 实例。

The issue seems caused by threads deadlock:

该问题似乎是由线程死锁引起的:

JavaScriptExecutor.run(JavaScriptExecutor.java:182)

I tried to call webclient.closeAllWindowsfor each instance but doesn't work.
I'm sure that ALLreferences to webClient objects are deallocated.

我试图为每个实例调用webclient.closeAllWindows但不起作用。
我确信对 webClient 对象的所有引用都已解除分配。

How can i properly cleanthe memory from webClient objects to avoid OOM? Garbage collector can't delete webClient objects due to thread lock.
I googled for hours but I don't find any working solution.
Thanks.

如何正确清理webClient 对象的内存以避免 OOM?由于线程锁定,垃圾收集器无法删除 webClient 对象。
我用谷歌搜索了几个小时,但没有找到任何可行的解决方案。
谢谢。

回答by Melloware

I have discovered the same bug with 2.15 and created a reproducible test case that shows the issue to the developers. Hopefully they will address it quickly. You can see the bug and my test case here...

我在 2.15 中发现了相同的错误,并创建了一个可重现的测试用例,向开发人员展示了这个问题。希望他们能尽快解决。您可以在此处查看错误和我的测试用例...

http://sourceforge.net/p/htmlunit/bugs/1638/

http://sourceforge.net/p/htmlunit/bugs/1638/