I have a memory leak problem with WebTest R_1810 (the latest available version 
at the time of this writing). What I am doing boils down to the code below (in 
reality, it is a bit more complex; MyWebtestCase would be highly configurable 
and I am instantiating and running it with different parameters).

When I set a breakpoint to the last line in main(), the thread dump looks like 
this:

Thread [main] (Suspended (breakpoint at line 14 in SampleRunner))       
        SampleRunner.main(String...) line: 14   
Daemon Thread [JS executor for com.gargoylesoftware.htmlunit.webcli...@9a288b] 
(Running)        
Daemon Thread [JS executor for com.gargoylesoftware.htmlunit.webcli...@c08c0a] 
(Running)        

If I add another set of w = new MyWebtestCase(); w.execute() to the main 
method, then I end up with three daemon threads.

The problem is that in my real application, each of these threads retains an 
instance of class com.steadystate.css.dom.CSSStyleSheetImpl which occupies 1 MB 
of heap space. So with each new MyWebtestCase instance and call to execute(), 
the available heap space decreases by 1 MB. The result is that with 1 GB of 
heap size, I can only run about 140 instances of my test before I get an 
OutOfMemory exception. The goal is to run 1500 tests, so I can not fix it by 
simply providing more heap space to the Java VM.

What can I do? I would expect the WebClient daemon thread to end as soon as the 
webtest Closure in execute() ends, but I don't know how to accomplish this.

Thanks for your help!
Beat

---
import com.canoo.webtest.*
import com.canoo.webtest.reporting.HTMLReportGenerator

public class SampleRunner {
  public static void main(def args) {
    println('Starting test execution.')
    MyWebtestCase w = new MyWebtestCase()
    w.execute()
    w = new MyWebtestCase()
    w.execute()
    println('Test execution finished.')
    HTMLReportGenerator.INSTANCE.shutdown()
        return
  }
}

public class MyWebtestCase extends WebtestCase {
  void execute() {
    webtest("check that WebTest is Google's top 'WebTest' result") {
      invoke "http://www.google.com/ncr";, description: "Go to Google (in 
English)"
      verifyTitle "Google"
      setInputField name: "q", value: "WebTest"
      clickButton "I'm Feeling Lucky"
      verifyTitle "Canoo WebTest"
    }
  }
}
---
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest

Reply via email to