ThumbnailEX memory leak...

Discussions about the ThumbnailEx control of GdPicture.NET.
Post Reply
rmbarbosa
Posts: 3
Joined: Fri Feb 25, 2011 5:58 pm

ThumbnailEX memory leak...

Post by rmbarbosa » Mon Apr 04, 2011 6:12 am

Hi,
i'm having a memory leak problem with your component and i think i found the cause...

I have a form that is loading documents/images to be checked by a user.
Each time i have a new document i load it like this:

Code: Select all

imgViewer.DisplayFromStream(mydocumentStream);
imgThumbs.LoadFromGdViewer(imgViewer)
...
after checking the app behaviour with a memory profiler i checked that i'm having memory leaks when i close the form because the imgviewer and imgthumbs controls are created dynamically.
I discovered that, in thumbnailex, you create new delegates and assign it to the gdviewer object events - PageChanged and DocumentClosed.
The thing is that the code you have is producing a common memory leak while using this event plumbing...
So, in my case, gdviewer PageChanged and DocumentClosed gets a lot of refs that are never release causing it to never be freed and so is thumbex.

After removing the imgthumbs i no longer had the mem leaks.
my sugestion is:
int your code, somehow in the middle of LoadFromGdViewer(GdViewer GdViewer), instead of just doing..

Code: Select all

    GdViewer.PageChangedEventHandler h1= new GdViewer.PageChangedEventHandler(mypagechanged);
    GdViewer.DocumentClosedEventHandler h2= new GdViewer.DocumentClosedEventHandler(mydocumentclosed);
    if (alreadylinked)
    {
       gdviewer.PageChanged -= h1;
       gdviewer.DocumentClosed -= h1;
    }
    gdviewer.PageChanged += h1;
    gdviewer.DocumentClosed += h1;
   
When you do += new EventHandler on the event it doesn’t really matter if this particular function has been added as a listener before, it will get added once per +=.
So i think it buggy..
you guys could do somehing like:

Code: Select all

    if (alreadylinked)
    {
       gdviewer.PageChanged -= mypagechanged;
       gdviewer.DocumentClosed -= mypagechanged;
    }
    gdviewer.PageChanged += mypagechanged;
    gdviewer.DocumentClosed += mydocumentclosed;
and would't suffer from the new delegate pointer.

but event then, the problem is that at the end you only clear the event when i run loadfromgdviewer so, i think some more is missing:

either you add some code to the dispose method of thumbex

Code: Select all

    if (alreadylinked)
        gdviewer.PageChanged -= mypagechanged;
        gdviewer.DocumentClosed -= mydocumentclosed;
or allow us, clients, to call any method to forcibly clear those event handlers links.

can u help?

User avatar
Loïc
Site Admin
Posts: 5586
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: ThumbnailEX memory leak...

Post by Loïc » Mon Apr 04, 2011 9:57 am

Hi,

Have you tried to call the ClearAllItems method before releasing the ThumbnailEx control ?


Kind regards,

Loïc

rmbarbosa
Posts: 3
Joined: Fri Feb 25, 2011 5:58 pm

Re: ThumbnailEX memory leak...

Post by rmbarbosa » Mon Apr 04, 2011 5:52 pm

hi,
yes but it doen't release the "link" with the viewer so the problem continues....

Jefferson
Posts: 6
Joined: Tue May 29, 2012 7:45 pm

Re: ThumbnailEX memory leak...

Post by Jefferson » Thu Aug 23, 2012 11:13 pm

Was this ever solved?? i have a document that i load thumbnails from the viewer. The document has around 1200 pages in it. when i call closedocument and clearallitems, my exe still sits around 1.2 GB. Any suggestions?

User avatar
Loïc
Site Admin
Posts: 5586
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: ThumbnailEX memory leak...

Post by Loïc » Thu Aug 23, 2012 11:20 pm

Try GC.Colllect().

If the problem persists try to reproduce it in a standalone application that you can send to http://support.gdpicture.com

Jefferson
Posts: 6
Joined: Tue May 29, 2012 7:45 pm

Re: ThumbnailEX memory leak...

Post by Jefferson » Fri Aug 24, 2012 6:36 pm

i think i figured out what it was... i was using a GdPicturePDF object and loading it into the viewer. calling closedocument on the viewer, doesn't seem to close the pdf also, so i was missing the closedocument call on the pdf object. thanks for the reply.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest