Re: Memory usage

Mark Overmeer <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.mail-box
Organization MARKOV Solutions
Message-ID <[email protected]>
* Daniel P. Berrange ([email protected]) [040312 12:56]:
> On Fri, Mar 12, 2004 at 12:18:05PM +0100, Mark Overmeer wrote:
> > * Daniel P. Berrange ([email protected]) [040312 12:13]:
> > > I've had a problem with memory usage too - I reduced memory consumption by 
> > > calling $message->destruct after finishing dealing with each message - but 
> > > I still can't process all 500MB of mail archives in one go without 
> > > restarting my script.
> > 
> > It would be nice to know why destruct() doesn't help.  Might be a
> > simple case of some final reference to be cleaned-up.  At the same
> > time, it may as well be cause by Perl trashing memory or other
> > memory leaks.  Various versions of Perl have memory leaks.
> 
> Could it be the Mail::Box::Manager object holding references to
> the Mail::Box objects - I currently just assume $manager->close 
> will cause all remaining references to the folder & thus its memory
> to be released ? I never hold any references to objects which
> aren't scoped to a short code block - my code basically looks like:

The situation is a little more complex.  The manager holds mailboxes,
and each mailbox holds messages, and the messages a header and a body.
Multipart and nested bodys hold list of bodies.

But at the same time, each of these objects refer back to their
parent, for instance: the body refers to its message.  For garbage
collection to work, the references "back" are weak references
(see Scalar::Util::weaken()).

In case I have forgotten to weaken one reference, somewhere, some
parts of the data structure may be kept alive, even after a descruct().
This is close to impossible to debug...
-- 
               MarkOv

------------------------------------------------------------------------
drs Mark A.C.J. Overmeer                                MARKOV Solutions
       [email protected]                          [email protected]
http://Mark.Overmeer.net                   http://solutions.overmeer.net
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.