[Kde-pim] [PATCH] Memory leak in IMAP IOSlave

Thomas McGuire mcguire at kde.org
Wed Feb 25 07:48:55 GMT 2009


Hi,

On Wednesday 25 February 2009 01:09:52 Tomi Junnila wrote:
> I've been looking at some memory leaks with kmail recently, and ran across
> another one (thanks to Chusslove Illich for a pointer to the Techbase
> article on debugging IOSlaves).
>
> The most recent problem I have found is that the IMAP IOSlave leaks memory
> because it doesn't delete the commands it creates (the QList in Qt4
> doesn't seem to autodelete).
>
> I've attached a Valgrind log that show the results of running kmail for a
> few minutes, and clicking the "Check Mail" button a few times.
>
> The second attachment is a proposed patch that simply deletes each command
> as soon as it has been removed from the completeQueue (the patch would
> benefit from a refactoring: a utility function should be made to combine
> the two operations). I have tested the patch, and Valgrind no longer
> reports memory leaks of this type (there are some others still left, but
> they are smaller). The patch is for 4.2.0, but did succeed with the latest
> version in SVN also (although with a 12-line offset in
> kioslave/imap4/imap4.cpp).
>
> I've not filed a bug on bugs.kde.org yet as it seems to be down (with a
> comment that it's offline to celebrate the KDE 4.2.0 release and request
> to come back on Jan 28).

Thanks for noticing this and for the patch! I would guess that this is a Qt4 
porting fallout.

But I'm not particular fond of the way 'delete' is peppered all over the code 
now, I think a better solution is to use boost::shared_ptr in all places where 
raw imapCommand pointers are used. This saves the deletes, and we can be sure 
not to forget a delete.
Could you change the patch so that boost::shared_ptrs are used and send that 
to reviewboard.kde.org (kdepim group)? Best with a typedef to save typing.

Regards,
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20090225/c3c5bc68/attachment.sig>
-------------- next part --------------
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/


More information about the kde-pim mailing list