Freeing GDI/GDI+ resources

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Freeing GDI/GDI+ resources

Esteban A. Maringolo-2
Hi,

    I'm reading a lot of GdiplusBitmaps and taking some data for statistical
purposes. I was wondering if i am freeing the resources properly.
    What would be the optimal way of handling this resources and leaving the
GC do his job in a proper way?

    An example of how I use it is:

    self imagesFiles do:
        [:each |
            | thumbImage avgImageColor |
            thumbImage := (GdiplusBitmap fromFile: each)
thumbnailWithExtent: cellExtent.
            "work with that image snipped"
            thumbImage finalize.
        ]

Is this correct, will the GdiplusBitmap instance just created, be GC'ed with
no problems?

I ask this, because in the task manager, showing GDI Objects column, i see a
lot of GDI objects when Dolphin is running, almost many as explorer.exe has.
And I don't know if i'm making a memory leak somewhere.

    Thanks in advance.

--
Esteban.


Reply | Threaded
Open this post in threaded view
|

Re: Freeing GDI/GDI+ resources

Louis Sumberg-2
Estaban,

As far as I know (from design and from use), resources are freed up
automatically, as per Dolphin's usual mechanism, and you don't even need to
use #finalize.  I've had apps where I've shown over a thousand bitmaps at a
time with no problem.

> I ask this, because in the task manager, showing GDI Objects column, i see
a
> lot of GDI objects when Dolphin is running, almost many as explorer.exe
has.
> And I don't know if i'm making a memory leak somewhere.

Frankly I'm not sure if the task manager distinguishes between GDI and GDI+
objects.  I too see a lot of GDI objects when Dolphin is running - e.g.,
when I open the PackageBrowser it seems to add about 50 GDI objects.  I
assume there's no memory leakage from OA's stuff, otherwise we would have
heard something by now.  Though I can't guarantee memory leakage from the
GDI+ stuff, I don't think there is any leakage.  BTW, a good tool to use to
see what objects are in your image is Chris Uppal's "Space Breakdown" -
thanks again, Chris.

For sure, if you do see memory problems or objects not being gc'd ...
holler.

-- Louis