HighTechTalks DotNet Forums  

.NET Compact Framework System.Windows.Forms.UserControl is leaking memory

Dotnet Framework (Compact Framework) microsoft.public.dotnet.framework.compactframework


Discuss .NET Compact Framework System.Windows.Forms.UserControl is leaking memory in the Dotnet Framework (Compact Framework) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Armin Sczuka
 
Posts: n/a

Default .NET Compact Framework System.Windows.Forms.UserControl is leaking memory - 11-23-2007 , 05:15 AM






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




Reply With Quote
  #2  
Old   
 
Posts: n/a

Default Re: .NET Compact Framework System.Windows.Forms.UserControl is leaking memory - 11-23-2007 , 01:52 PM






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 (AT) newsgroup (DOT) nospam> wrote

Quote:
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






Reply With Quote
  #3  
Old   
Armin Sczuka
 
Posts: n/a

Default Re: .NET Compact Framework System.Windows.Forms.UserControl is leaking memory - 11-24-2007 , 07:31 AM



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

Quote:
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 (AT) newsgroup (DOT) nospam> wrote in message
news:OUy9pIcLIHA.1204 (AT) TK2MSFTNGP03 (DOT) 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






Reply With Quote
  #4  
Old   
Peter Foot [MVP]
 
Posts: n/a

Default Re: .NET Compact Framework System.Windows.Forms.UserControl is leaking memory - 11-26-2007 , 04:44 AM



This is a Console app, can you repro it in a windows forms application?

Peter

--
Peter Foot
Microsoft Device Application Development MVP
www.peterfoot.net | www.inthehand.com
In The Hand Ltd - .NET Solutions for Mobility

"Armin Sczuka" <sczuka (AT) newsgroup (DOT) nospam> wrote

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

Quote:
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 (AT) newsgroup (DOT) nospam> wrote in message
news:OUy9pIcLIHA.1204 (AT) TK2MSFTNGP03 (DOT) 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






Reply With Quote
  #5  
Old   
Armin Sczuka
 
Posts: n/a

Default Re: .NET Compact Framework System.Windows.Forms.UserControl is leaking memory - 11-26-2007 , 06:52 AM



Yes Peter,

It's the same there. Actually the objects seams to be collected if you
manually call IDisposable.Dispose().

/Armin

Quote:
"Peter Foot [MVP]" <feedback (AT) nospam-inthehand (DOT) com> wrote in message
news:97643E3A-D770-4DAF-808B-1044095CBB2A (AT) microsoft (DOT) com...
This is a Console app, can you repro it in a windows forms application?

Peter

--
Peter Foot
Microsoft Device Application Development MVP
www.peterfoot.net | www.inthehand.com
In The Hand Ltd - .NET Solutions for Mobility




Reply With Quote
  #6  
Old   
dbgrick
 
Posts: n/a

Default Re: .NET Compact Framework System.Windows.Forms.UserControl is lea - 11-26-2007 , 09:30 AM



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

"Armin Sczuka" wrote:

Quote:
Yes Peter,

It's the same there. Actually the objects seams to be collected if you
manually call IDisposable.Dispose().

/Armin

"Peter Foot [MVP]" <feedback (AT) nospam-inthehand (DOT) com> wrote in message
news:97643E3A-D770-4DAF-808B-1044095CBB2A (AT) microsoft (DOT) com...
This is a Console app, can you repro it in a windows forms application?

Peter

--
Peter Foot
Microsoft Device Application Development MVP
www.peterfoot.net | www.inthehand.com
In The Hand Ltd - .NET Solutions for Mobility





Reply With Quote
  #7  
Old   
td
 
Posts: n/a

Default Re: .NET Compact Framework System.Windows.Forms.UserControl is lea - 12-28-2007 , 05:49 AM



Hi,
I have just a question :
If my usercontrol contains controls, should I have to dispose all objects
before disposing my usercontrol ?
Thanks

"dbgrick" <dbgrick (AT) discussions (DOT) microsoft.com> a écrit dans le message de
news: 3D932C91-C963-4675-8514-D7CA911BF325...soft (DOT) com...
Quote:
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

"Armin Sczuka" wrote:

Yes Peter,

It's the same there. Actually the objects seams to be collected if you
manually call IDisposable.Dispose().

/Armin

"Peter Foot [MVP]" <feedback (AT) nospam-inthehand (DOT) com> wrote in message
news:97643E3A-D770-4DAF-808B-1044095CBB2A (AT) microsoft (DOT) com...
This is a Console app, can you repro it in a windows forms application?

Peter

--
Peter Foot
Microsoft Device Application Development MVP
www.peterfoot.net | www.inthehand.com
In The Hand Ltd - .NET Solutions for Mobility







Reply With Quote
  #8  
Old   
 
Posts: n/a

Default Re: .NET Compact Framework System.Windows.Forms.UserControl is lea - 12-28-2007 , 09:20 AM



I would say yes, it's a good idea to do so.


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com


"td" <thierrydotdistelatwurthdotfr> wrote

Quote:
Hi,
I have just a question :
If my usercontrol contains controls, should I have to dispose all objects
before disposing my usercontrol ?
Thanks

"dbgrick" <dbgrick (AT) discussions (DOT) microsoft.com> a écrit dans le message de
news: 3D932C91-C963-4675-8514-D7CA911BF325...soft (DOT) com...
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

"Armin Sczuka" wrote:

Yes Peter,

It's the same there. Actually the objects seams to be collected if you
manually call IDisposable.Dispose().

/Armin

"Peter Foot [MVP]" <feedback (AT) nospam-inthehand (DOT) com> wrote in message
news:97643E3A-D770-4DAF-808B-1044095CBB2A (AT) microsoft (DOT) com...
This is a Console app, can you repro it in a windows forms
application?

Peter

--
Peter Foot
Microsoft Device Application Development MVP
www.peterfoot.net | www.inthehand.com
In The Hand Ltd - .NET Solutions for Mobility









Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.