[Digikam-devel] I'm back with questions - AutoCorrections tool memory usage and resource leaks

Matthias Welwarsky matze at welwarsky.de
Wed Mar 3 12:44:32 GMT 2010


Hi Gilles,

On Wednesday 03 March 2010 11:06:01 you wrote:
> Hi Mathias,
> 
> Yes, you have right. All recent changes in svn trunk come from me.
> The deep copy refimage is not necessary here of course. it can be removed.

OK, how would the code look like then?

m_refImage = *refImage?

> 
> > The second problem, which leads to
> > the mem leak is the undefined lifetime of the effect filters, especially
> > those in the PreviewList.
> >
> > The filter instances are never explicitely destroyed. They are either
> > tied to the lifetime of the AutoCorrectionTool instance or the lifetime
> > of the PreviewList. But the PreviewList is created and tied to the
> > _parent_ object of the AutoCorrectionTool, which is unfortunately the
> > ImagePlugin_Core instance, which has near infinite lifetime. I think you
> > get the picture ;)
> 
> What the real solution here ? To pass a widget object as parent
> instead image_plugin core instance ?

I tried that, by creating PreviewList as with "this" as the parent object, but 
I get a crash on application shutdown. For now my solution is to explicitly 
delete the PreviewList in the AutoCorrectionTool destructor. It's a bit 
strange, I thought that PreviewList would be destroyed together with 
AutoCorrectionTool due to the parent/child relation, but it's not the case, I 
see the AutoCorrectionTool destructor execute but not the PreviewList 
destructor. PreviewList is destructed on application shutdown only and there I 
get a crash.

> 
> > I hope I didn't annoy you with this long storytelling, but it teaches to
> > be careful with the lifetime of objects, especially since memory leaks
> > like this don't show up in valgrind, due to the parent/child relationship
> > the parent QObject will always hold a pointer to all its children and
> > valgrind will not notice the leak.
> >
> > So, the patch for the PreviewList is trivial, but I would like your
> > advice for fixing the image copying in the >effect filters.
> 
> Well, i'm waiting your patch...

OK. Will post something tonight.

regards,
matthias




More information about the Digikam-devel mailing list