"Memleak" in test-script for memleak ... #17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
OK, this is not really a memleak, but the $mech-object keeps a history up to 8675309 entries and for normal sites this can get huge!
-> for testing memleaks we don't need the $mech history
I was hunting a memleak with the code from Leak-Hunting in my app and at the end, after many hours spend i was totally confused that the memleak must be in Template::Toolkit! After adding many whitespaces to a template, the memleak gets bigger.
After some sleep and thinking about the test script i found the "memleak" in 3 minutes. Keeping all the rendered stuff alive in the $mech object won't help to find memleaks. So i added a "don't keep history" option to the $mech object and now i don't have a memleak anymore!
From the documentation of WWW::Mechanize:
=head2 $mech->stack_depth( $max_depth )
Get or set the page stack depth. Use this if you're doing a lot of page
scraping and running out of memory.
A value of 0 means "no history at all." By default, the max stack depth
is humongously large, effectively keeping all history.