Subject: | prove uses a lot of memory when running one test with large output |
I have a single test script that runs about 1.5 million tests (that is,
it produces about 1.5 million lines of TAP output). Running this test
causes "prove" to use about 450MB of RAM.
Using a simple memory debugging tool that I wrote around
Devel::Gladiator, I can see that the items taking up the most memory are
three hashes, with these keys:
{_closures,formatter,name,ok_callbacks,parser,show_count}
{iterator,ordered_tokens,parser,tokens,version}
{_grammar,_iter,_iterator,_spool,actual_failed,actual_passed,code_for,fa
iled,grammar_class,in_todo,iterator_factory_class,ok_callbacks,parse_err
ors,passed,plan,pragma,result_factory_class,results,skipped,start_time,t
ap,tests_planned,tests_run,todo,todo_passed,version}
I haven't drilled into the code too much to examine what these are,
although I'd guess the top one is a TAP::Formatter::Console::Session.
Now, as a side note, I suspect that some people may respond, "your
script shouldn't run so many tests and it should be parallelized somehow
instead". Well, yes, that's actually how I got it *down* to running 1.5
million tests--it used to run 60 million. There's actually a fairly
rational reason it's running so many tests--it has to test a large
number of combinations of input, all of which are unique.
The test script itself uses only 60MB of RAM for all its work, but prove
is expanding linearly, it seems, with the number of tests I run.