perlwww-mechanizemozrepl

Is the only way to disconnect WWW::Mechanize::Firefox from mozrepl destruction of the objects?


As the title says I'm trying to make a perl daemon which, being long-running I want to be sane on resource usage.

All the examples / documentation I've seen doesn't seem to mention a way to disconnect a session.

The best documentation on the topic I can find in WWW::Mechanize::Firefox::Troubleshooting Where it's suggested the object (and connection?) is kept alive until global destruction.

In short, I've seen no 'disconnect' function, and wonder if I'm missing something.


Solution

  • Disconnection seems to be handled via destructors. Perl uses special DESTROY methods for this. It is not advisable to call this method manually.

    You need to decrease the refcount of your $mech object in order to get it destroyed automatically. This happens when the variable drops out of scope, in the Global Destruction Phase at the end of the process, or (in the case of objects), by assigning something different to your variable, e.g.

    $mech = undef;
    

    To completely deallocate any variable, you can also

    undef $mech; # which btw is the answer provided in the FAQ you linked
    

    The differences are subtle, and irrelevant in this case.