Menu

#1309 Memory Leak

Latest SVN
closed
nobody
None
5
2014-10-09
2011-07-27
Danny
No

Running the following code which just adds a script element ends up with residual objects in the heap (for example DomAttr). The number of these increases every run.

WebClient webClient = new WebClient(BrowserVersion.FIREFOX_3_6);
webClient.setCssEnabled(true);
webClient.setJavaScriptEnabled(false);
WebRequest setting = new WebRequest(new URL("http://www.google.com"));
final HtmlPage htmlPage = webClient.getPage(setting);
NodeList list = htmlPage.getElementsByTagName("body");
HtmlElement bodyElement = (HtmlElement)list.item(0);               
HtmlElement scriptElement = (HtmlElement) htmlPage.createElement("script");
bodyElement.appendChild(scriptElement);
webClient.closeAllWindows();

Discussion

  • RBRi

    RBRi - 2013-08-26
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,13 +1,16 @@
     Running the following code which just adds a script element ends up with residual objects in the heap (for example DomAttr). The number of these increases every run. 
    
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +
     WebClient webClient = new WebClient(BrowserVersion.FIREFOX_3_6);
    -                webClient.setCssEnabled(true);
    -                webClient.setJavaScriptEnabled(false);
    -                WebRequest setting = new WebRequest(new URL("http://www.google.com"));
    -                final HtmlPage htmlPage = webClient.getPage(setting);
    -                NodeList list = htmlPage.getElementsByTagName("body");
    -                HtmlElement bodyElement = (HtmlElement)list.item(0);               
    -                HtmlElement scriptElement = (HtmlElement) htmlPage.createElement("script");
    -                bodyElement.appendChild(scriptElement);
    -                
    -                webClient.closeAllWindows();
    +webClient.setCssEnabled(true);
    +webClient.setJavaScriptEnabled(false);
    +WebRequest setting = new WebRequest(new URL("http://www.google.com"));
    +final HtmlPage htmlPage = webClient.getPage(setting);
    +NodeList list = htmlPage.getElementsByTagName("body");
    +HtmlElement bodyElement = (HtmlElement)list.item(0);               
    +HtmlElement scriptElement = (HtmlElement) htmlPage.createElement("script");
    +bodyElement.appendChild(scriptElement);
    +webClient.closeAllWindows();
    +
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
     
  • RBRi

    RBRi - 2014-10-09

    Did some tests today; let your code run 10.000 times (more than 2h) with the current code from svn. There was no notable memory leak.

    So the bug seems to be fixed by one of our last memory leak fixes.

     
  • RBRi

    RBRi - 2014-10-09
    • status: open --> closed
     

Log in to post a comment.