Re: Memory usage
"Daniel P. Berrange" <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.mail-box |
|---|---|
| Message-ID | <[email protected]> |
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: my $manager = Mail::Box::Manager->new(); foreach my $folder (@ARGV) { my $box = $manager->open(folder => $folder, extract => 'LAZY'); die "Cannot open folder $folder" unless $box; &load_folder($box); $manager->close($box, write => 'NEVER'); } exit; sub load_folder { my $box = shift; foreach my $message ($box->messages) { ...load message into db... $message->destruct; } } Dan. -- |=- http://www.berrange.com/~dan/gpgkey.txt -=| |=- [email protected] - Daniel Berrange - [email protected] -=|
signature.asc
(application/pgp-signature, 232 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQFAUaYCvTAeyOKLMk4RAitAAKCft5R9eDedpeTpMbyyMy6CVHxkyACfQRZ4 ITBKTbOem+UhcwwgcXFDWJA= =whpT -----END PGP SIGNATURE-----