Monks I hope this makes sense - I must say I'm struggling to get my head around it I'm not very experienced with mod_perl. Background My company offers a web product which allows users their own sub domains. All the content of the sub domains are dynamically generated from our database (user has contol over look and feel). The server runs mod_perl and all the Perl scripts and modules are compiled on the webserver startup using Apache::RegistryLoader. The httpd.conf is set up so the first thing that is called when a client accesses the site is index.cgi, this handles what data (i.e what site) to display to the client. There is another handler inside the conf
<Location /site/> SetHandler perl-script PerlHandler Apache::ROOT::cgi_2dbin::index_2ecgi PerlSendHeader On AllowOverride None
which I guess handles the url rewrite. The problem i'm having is that any modules loaded (and an object subsequently created) within this index.cgi never seems to go out of scope. For instance I have two modules Session and Community, where and instance gets created on every call of index.cgi. Just to see what was going on I added the constructor
sub DESTROY { my $self = shift; my $me = ref($self); print carp "i'm dying.....$me\n"; }
to both of the modules, now when the script has finished and the objects HAVE gone out of scope the distructors are not called. However very regularly I get 'attempt to free unreferenced scalar' which coincides with what the perdoc says about this problem. Now when I shut down the webserver I suddenly get a whole load of the modules shut down i.e.
[Tue Feb 19 11:08:57 2002] null: i'm dying.....Session [Tue Feb 19 11:08:57 2002] null: at /dev/null line 0 [Tue Feb 19 11:08:57 2002] null: i'm dying.....Community [Tue Feb 19 11:08:57 2002] null: at /dev/null line 0 [Tue Feb 19 11:08:57 2002] null: i'm dying.....Session [Tue Feb 19 11:08:57 2002] null: at /dev/null line 0 [Tue Feb 19 11:08:57 2002] null: i'm dying.....Community [Tue Feb 19 11:08:57 2002] null: at /dev/null line 0 [Tue Feb 19 11:08:57 2002] null: i'm dying.....Session [Tue Feb 19 11:08:57 2002] null: at /dev/null line 0 [Tue Feb 19 11:08:59 2002] [notice] caught SIGTERM, shutting down
Also on shutdoen I get a series of
[Tue Feb 19 11:11:39 2002] null: Attempt to free unreferenced scalar.
So it seems the objects never 'automatically' go out of scope !! Has anyone experienced anything like this. I have looked on supersearch but to no avail ! Any guidance will be greatly appreciated.

In reply to Modules not going out of scope by ropey

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.