Confused with Collection (GC)

R

rogerwatkins

hi All,
I am slightly confused over the behaviour I am seeing with my app.
I am running on WinCE5.0, .NETCF2.0 SP1, ARM core device.
My application basically creates controls which are displayed on the
form. When necessary, certain controls are removed and then manually
disposed of to release resource (RAM) whilst other controls are added.
To do this, I use the .Dispose() method of my control (these are
custom controls which are derived from the Control class).

My problem is that I am getting OOM (Out of memory) exceptions where I
would not expect it.

My controls use bitmaps to load and display images within the control,
these bitmaps are local to the scope of the control, so I would expect
that when I dispose of the control (using .Dispose()), the bitmaps
within the control are also release by the system...
The thing is, it seems to work ( I don't get OOMs), if I explicitly
dispose of the bitmaps within an over-rided Dispose() method in the
control.. <make sense?>
Basically, I get around it by over-riding the .Dispose(bool disposing)
method in the control, and disposing all the bitmaps that the control
uses within that.

This to me does not make sense, as I have been led to believe that
when an object goes out of scope or is disposed of, all its resources
will be released.

So, my question is this
Have I mis-understood how the resource allocation/de-allocation works,
or is there something else going on here?

many thanks for any input
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top