Re: Memory usage

Mark Overmeer <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.mail-box
Organization MARKOV Solutions
Message-ID <[email protected]>
* Miah Gregory ([email protected]) [040402 03:03]:
> On Fri, 2004-03-12 at 11:18, Mark Overmeer wrote:
> I've now tried the $message->destruct() method for keeping memory usage
> down, and can confirm that it does help a lot
> Memory usage seems to creep up slowly to that point, but I'm unsure why.

Eventhough the head and body get destructed, there still is some data
in the message object and in the folder about the message object.

> However, when using MailDir's, there are some side effects.

Yep, I just realized that destruct() is too mbox-centric.  At least
what is wrong is that all messages which are destructed have to be
removed... that is not right.  Therefore remove line 91 from
Mail/Box/Message/Destructed.pm
 <   $message->label(deleted => 1);

> 1) Loads of errors (two lines per message I think):
> ERROR: You cannot take the head of a destructed message
> ERROR: You cannot take the body of a destructed message

For the same reason as the above, we need to add to Destructed.pm:
                                                                                
  sub modified(;$)
  {  my $self = shift;
                                                                                
     $self->log(ERROR => 'Do not set the modified flag on a destructed message')
        if @_ && $_[0];
                                                                                
     0;
  }
                                                                                
  sub isModified() { 0 }
                                                                                

> 2) In Maildir.pm, writeMessages, around line 333, there is a check to
> see whether the folder is empty. However it seems to rely on the
> contents of @messages, which is, I'm guessing, now empty. Having
> satisfied the condition, it proceeds to delete the MailDir.

True.

> I was about to call 2 a bug, but in fact there is a check for a flag
> MB_remove_empty. So instead, I would suggest that the default behaviour
> should /not/ be to delete empty folders - it's highly confusing, and I
> would guess, not obvious behaviour.

From a user's point of view, removing empty folders is nice.  That's
why it grew that way.  Now that cannot be changed anymore without
breaking existing programs.  Happily, folders are re-created
automatically when you wish.

> Also, some mail handling programs such as courier imap write control
> information into the top level of the MailDir, causing the rmdir to
> fail. It might be better to perform a scan across the whole directory
> before deciding it's empty, and only deleting the structure if no files
> are found.

Well, my idea was to have "remove_when_empty" to be silly: just try to
remove the directory, but do not try to be smart about other applications,
like courier, on the system.  Therefore, the rmdir's are not checked for
success.

> Just my 2p, this is meant as constructive critisism, nothing more.

Feel invited to contribute more critisism (or code, docs, bugs)
-- 
               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.