Subject: | memory leak with $mojo in closure |
I added Test::Memory::Cycle to a test suite to check for memory leaks on my app object, and it found this leak in your plugin:
# Cycle #1
# Test::MyApp A->{ua} => Mojo::UserAgent B
# Mojo::UserAgent B->{server} => Mojo::UserAgent::Server C
# Mojo::UserAgent::Server C->{app} => MyApp D
# MyApp D->{renderer} => Mojolicious::Renderer E
# Mojolicious::Renderer E->{helpers} => %F
# %F->{random_string} => &G
# closure &G, $mojo => $H
# $H => MyApp D
It looks like $mojo should be weakened when it is closed over in the
random_string sub. (See Scalar::Util::weaken.)