I suppose it is depend on context.
- It is reused when
&funccall is made - It is created for all other calls
I have this code where I got unexpected eval call at line 1004:
sub save_context {
@DB::context = ( \@_, (caller 2)[8..10], $@, $_ ); # line 1004
print_state "\nTRAPPED IN ", "\n\n" if _ddd;
DB::state( 'inDB', 1 );
}
And this stacktrace:
DB /x/local/lib/perl5/Devel/DebugHooks.pm 1419 DB::orig_frames
DB /x/local/lib/perl5/Devel/DebugHooks.pm 1460 DB::push_frame
DB /x/local/lib/perl5/Devel/DebugHooks.pm 1004 DB::__ANON__[/x/local/lib/perl5/Devel/DebugHooks.pm:1460]
DB /x/local/lib/perl5/Devel/DebugHooks.pm 1004 (eval)
DB /x/local/lib/perl5/Devel/DebugHooks.pm 1251 DB::save_context
DB /x/local/lib/perl5/Devel/DebugHooks.pm 1288 DB::DB_my 1
MyApp::Controller::User /x/lib/MyApp/Controller/User.pm 41 DB::DB 1
Mojolicious /x/local/lib/perl5/Mojolicious.pm 133 MyApp::Controller::User::list
Mojolicious::Plugins /x/local/lib/perl5/Mojolicious/Plugins.pm 15 Mojolicious::__ANON__[/x/local/lib/perl5/Mojolicious.pm:133]
...
From my log file I can see that DBIx::Class::DESTROY sub is called:
DB::sub DB::state: l:1 d:0 s:5 t:0 /x/local/lib/perl5/Devel/DebugHooks.pm:1004 --> DBIx::Class::DESTROY
Why object destruction is postponed? I suppose that is related to @_ in some way
Any suggestions appreciated about that what may trigger object destruction here
DESTROYis called. See answer below – Eugen Konkov Jan 8 at 14:06