[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-pim
Subject:    [Kde-pim] kmail memory consumption when importing mails
From:       Will Stephenson <lists () stevello ! free-online ! co ! uk>
Date:       2005-03-21 10:24:33
Message-ID: 200503211024.34643.lists () stevello ! free-online ! co ! uk
[Download RAW message or body]

KMail consumes a lot of memory when importing messages.   I got 10% of the way 
through importing a 700Mb mbox into an mbox folder, and the kmail process had 
already consumed 50% of my 1Gb ram, 1Gb swap according to top.  Maildir 
format performance was the same.  Valgrind doesn't show any leaks, and having 
spoken with Till and looked at it would seem that the messages are created in 
the KMKernel::dcopAddMessage methods and are not unGot or deleted until kmail 
quits.

The following patch[*] unGetMsg()s immediately after adding them to the folder 
in dcopAddMessage*.  I have checked to see if calling KMFolder::addMsg() 
results in any persistent KMMessage *'s that will not be cleaned up by the 
unGetMsg() and haven't seen anything obviously dangerous, but could someone 
more familiar with KMail tell me if this fix is a bad idea?

One side effect is that it really slows down mail import.  But you don't get 
OOM killed.

Will

[*] diff against kmkernel.cpp, no cvs diff today
-- 
Will Stephenson
IRC: Bille

["kmail_eats_mem_importing.diff" (text/x-diff)]

--- kmkernel.cpp~	2005-03-21 10:21:50.105280584 +0000
+++ kmkernel.cpp	2005-03-21 10:06:09.023069451 +0000
@@ -703,7 +703,9 @@
         if ( !msgId.isEmpty() ) {
           mAddMessageMsgIds.append( msgId );
         }
-        if ( folder->addMsg( msg ) == 0 ) {
+        int index;
+        if ( folder->addMsg( msg, &index ) == 0 ) {
+          folder->unGetMsg( index );
           retval = 1;
         } else {
           retval =- 2;
@@ -756,7 +758,9 @@
     KMFolder *folder = the_folderMgr->findOrCreate( foldername, false );
 
     if ( folder ) {
-      if ( folder->addMsg( msg ) == 0 ) {
+      int index;
+      if ( folder->addMsg( msg, &index ) == 0 ) {
+        folder->unGetMsg( index );
         retval = 1;
       } else {
         retval =- 2;


_______________________________________________
kde-pim mailing list
kde-pim@kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic