Possible memory leak when resetting session inside a loop
See original GitHub issueHi guys.
I think there is a memleak in the session object when you reset your session attributes while looping via repeat/asLongAs/forever/etc. statements. I use session reset to mimic close workload model of the SUT.
Please see below.
The environment:
- current Gatling version: 2.3.1
- OS version: macOS High Sierra 10.13.6
- Gatling run via current SBT plugin (gatling/gatling-sbt-plugin-demo)
The steps:
- clone the newest gatling/gatling-sbt-plugin-demo project
- enable verbose logback output to see all requests/session bags
- edit the ComputerWorld simulation to run in a loop with session reset:
class ComputerWorld extends Simulation {
val httpProtocol = http
.baseURL("http://computer-database.gatling.io")
.acceptHeader("""text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8""")
.acceptEncodingHeader("""gzip, deflate""")
.acceptLanguageHeader("""en-gb,en;q=0.5""")
.userAgentHeader("""Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Firefox/31.0""")
val computerDbScn = scenario("Computer Scenario").repeat(10, "repeat_counter") {
pause(5).exec(_.reset)
.exec(http("getComputers")
.get("/computers")
.check(
status is 200,
regex("""\d+ computers found"""),
css("#add", "href").saveAs("addComputer")))
.exec(http("addNewComputer")
.get("${addComputer}")
.check(substring("Add a computer")))
.exec(_.set("homeComputer", s"homeComputer_${ThreadLocalRandom.current.nextInt(Int.MaxValue)}"))
.exec(http("postComputers")
.post("/computers")
.formParam("name", "${homeComputer}")
.formParam("introduced", "2015-10-10")
.formParam("discontinued", "2017-10-10")
.formParam("company", "")
.check(substring("${homeComputer}")))
}
setUp(computerDbScn.inject(
atOnceUsers(1)
).protocols(httpProtocol))
}
- run the ComputerWorld simulation, i.e.:
sbt "gatling:testOnly computerdatabase.ComputerWorld"
- observe the contents of the session in the logback output
Actual result: The size of the blockStack inside session increases with new instances of ExitOnCompleteLoopBlock added in each loop iteration, i.e.:
List(ExitOnCompleteLoopBlock(repeat_counter), ExitOnCompleteLoopBlock(repeat_counter), ExitOnCompleteLoopBlock(repeat_counter), ExitOnCompleteLoopBlock(repeat_counter), ExitOnCompleteLoopBlock(repeat_counter), ExitOnCompleteLoopBlock(repeat_counter), ExitOnCompleteLoopBlock(repeat_counter), ExitOnCompleteLoopBlock(repeat_counter), ExitOnCompleteLoopBlock(repeat_counter), ExitOnCompleteLoopBlock(repeat_counter), ExitOnCompleteLoopBlock(repeat_counter), ExitOnCompleteLoopBlock(repeat_counter))
Moreover, the simulation loops forever instead of stopping after requested number of repetitions, which bothers me even more.
Expected result: There should be only one instance of ExitOnCompleteLoopBlock in the session, like it is when the session is not reset inside a loop. The simulation should stop after looping the requested times.
I hope you’ll be able to reproduce and fix this 😃
Thanks for the great piece of software and best regards, Adam
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (8 by maintainers)
Top GitHub Comments
Note that
Session#reset
will no longer remove Gatling internal attributes, including caches. Also note that Gatling 3 will support closed workload model.closed by 8164abd