Since upgrading to 10/11/2002 sources from CVS I have noticed a drastically
increased amount of RAM being used by my test suite. I'm seeing my RAM usage
top out well over 100 MB where it used to consume more like 30 MB. Further the
RAM usage grows during its entire execution. Sounds like a memory leak of some
sort, eh?
I think I have found the cause. There is a HashMap in
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine named pageInfos_ that
appears to hold a reference to every page visited by the instance of
com.gargoylesoftware.htmlunit.WebClient. Apparently each instance of
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.PageInfo holds a
reference to an instance of com.gargoylesoftware.htmlunit.html.HtmlPage. You
have to follow the reference graph a ways to see this. I discovered it using
OptmizeIt. The result is that instances of WebClient get bigger and bigger as
you continue using them to visit pages.
I'm changed by test suite to not reuse instances of WebClient to work around the
problem. Instead it creates a new one for every test. This is probably a better
design for my test suite any way.
Mike Bresnahan
|