Subject: | There is a circular reference in OX |
Once you create the OX application, the object is never released due to circular reference.
use strict;
use Test::More;
use Scalar::Util qw(weaken);
{
package MyApp;
use OX;
}
my $weak = MyApp->new;
weaken($weak);
ok(!$weak, 'reference is cleared');
done_testing();
As far as I was able to detect it the problem lies in a container construction in OX/Application/Role/Router.pm lines
28: my $router = $self->build_router($s);
29: $self->configure_router($router);
and OX/Application.pm lines
36: $self->build_middleware($s);
45: my $app = $self->build_app($s);
65: $self->_flush_request_services
where the container ($self) is referenced inside block subroutine.
When you replace $self by $s->parent you break the circular reference and the test passes.