
Signature
Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com
Hi Chris,
if you create for example a new Console Application, add reference to System.Windows.Forms and run:
using System;
using System.Collections.Generic;
using System.Text;
namespace TestGC
{
class Good
{
private byte[] _SomeData = new byte[1024];
~Good()
{
}
}
class Bad : System.Windows.Forms.Control
{
private byte[] _SomeData = new byte[1024];
~Bad()
{
}
}
class Program
{
static void Main(string[] args)
{
Good good;
Bad bad;
while (true)
{
good = new Good();
bad = new Bad();
System.Threading.Thread.Sleep(1);
}
}
}
}
If you run it an set a breakpoint on each finalizer you will see that the finalizer for Bad will never hit and the memory will go down (on your device).
Best Regards,
Armin
> And you have a repro? I've not heard of it as an issue and since the CF is
> several years old, I'd suspect we'd have heard of someone having the problem
[quoted text clipped - 16 lines]
>> Thanks,
>> Armin
Peter Foot [MVP] - 26 Nov 2007 10:44 GMT
This is a Console app, can you repro it in a windows forms application?
Peter

Signature
Peter Foot
Microsoft Device Application Development MVP
www.peterfoot.net | www.inthehand.com
In The Hand Ltd - .NET Solutions for Mobility
Hi Chris,
if you create for example a new Console Application, add reference to System.Windows.Forms and run:
using System;
using System.Collections.Generic;
using System.Text;
namespace TestGC
{
class Good
{
private byte[] _SomeData = new byte[1024];
~Good()
{
}
}
class Bad : System.Windows.Forms.Control
{
private byte[] _SomeData = new byte[1024];
~Bad()
{
}
}
class Program
{
static void Main(string[] args)
{
Good good;
Bad bad;
while (true)
{
good = new Good();
bad = new Bad();
System.Threading.Thread.Sleep(1);
}
}
}
}
If you run it an set a breakpoint on each finalizer you will see that the finalizer for Bad will never hit and the memory will go down (on your device).
Best Regards,
Armin
"<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote in message news:uZ1y2pgLIHA.4880@TK2MSFTNGP03.phx.gbl...
> And you have a repro? I've not heard of it as an issue and since the CF is
> several years old, I'd suspect we'd have heard of someone having the problem
> before now.
>
>
> --
>
> Chris Tacke, eMVP
> Join the Embedded Developer Community
> http://community.opennetcf.com
>
>
> "Armin Sczuka" <sczuka@newsgroup.nospam> wrote in message
> news:OUy9pIcLIHA.1204@TK2MSFTNGP03.phx.gbl...
>> Hello,
>>
>> I figured out that all objects based on System.Windows.Forms.UserControl
>> are
>> never disposed by the Compact Framework GC. This problem occours only
>> under
>> Windows CE not with Win32/ Win64.
>>
>> Is this a known issue?
>>
>> Is there any fix for it?
>>
>> How about the .NET Compact Framework 3.5? Is it fixed there?
>>
>> Thanks,
>> Armin
>>
>>
>>
>
>
Armin Sczuka - 26 Nov 2007 12:52 GMT
Yes Peter,
It's the same there. Actually the objects seams to be collected if you
manually call IDisposable.Dispose().
/Armin
> This is a Console app, can you repro it in a windows forms application?
>
> Peter
dbgrick - 26 Nov 2007 15:30 GMT
Armin,
You answered your own question. Just like for forms, you controls, you must
call dispose for the control to be collected. If you do not, then the
control will never be marked for collection. As as test you can create a
form and then not call the dispose in the finally method, and you will see
the memory never be deallocated. I've been called in on several projects
that were leaking memory and that is usually the reason for the leakage.
Regards,
Rick D.
Contractor
> Yes Peter,
>
[quoted text clipped - 6 lines]
> >
> > Peter
td - 28 Dec 2007 11:49 GMT
Hi,
I have just a question :
If my usercontrol contains controls, should I have to dispose all objects
before disposing my usercontrol ?
Thanks
> Armin,
> You answered your own question. Just like for forms, you controls, you
[quoted text clipped - 19 lines]
>> >
>> > Peter
<ctacke/> - 28 Dec 2007 15:20 GMT
I would say yes, it's a good idea to do so.

Signature
Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com
> Hi,
> I have just a question :
[quoted text clipped - 27 lines]
>>> >
>>> > Peter