C
Chriz
Hello,
I´m programming a C# application on Windows CE 5.0 and CF 2.0.
This application should run permanently (24h/7days). I realized that the
garbage collector (gc) does not free all the allocated memory. Thus after a
while (a few days) an OutOfMemory-exception occurs.
I wrote a small test application:
In a function I created a form (Form frm = new Form() which is shown by
ShowDialog(). I figured out that after closing this form and leaving the
function, some memory fragments won´t be freed by the gc (>= 4KB).
This behavior occurs when member variables (lists, bitmaps,...) are declared
in this created form. If I declare this member variables within a function
(stack) the memory will be totally freed.
As I can see there is a bug in Visual Studio 2005. The object ‘components‘
is created, but never used by the designer. The overridden dispose-function
in the designer.cs frees all the objects in the componets-object but – as I
said – this object is never beeing used.
I customized all overrides of dispose() in the designer.cs:
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed;
otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && this.Controls != null)
{
this.components = new System.ComponentModel.Container();
foreach (Control o in this.Controls)
components.Add(o);
components.Dispose();
}
base.Dispose(disposing);
}
Now, most of the memory is freed but periodically there still remain some
fragments in the memory (>=4KB up to 64KB (?)).
I also noticed that running this application on a desktop pc with the “big“
:NET framework – no memoryloak persists!
Has anyone noticed the same behaviour and/or found a solution for it?
Does anyone have experience with applications running round the clock on
Windows CE / CF 2.0?
Are there bugs in the gc on compact framework?
Thanks for your help, best regards Chris
I´m programming a C# application on Windows CE 5.0 and CF 2.0.
This application should run permanently (24h/7days). I realized that the
garbage collector (gc) does not free all the allocated memory. Thus after a
while (a few days) an OutOfMemory-exception occurs.
I wrote a small test application:
In a function I created a form (Form frm = new Form() which is shown by
ShowDialog(). I figured out that after closing this form and leaving the
function, some memory fragments won´t be freed by the gc (>= 4KB).
This behavior occurs when member variables (lists, bitmaps,...) are declared
in this created form. If I declare this member variables within a function
(stack) the memory will be totally freed.
As I can see there is a bug in Visual Studio 2005. The object ‘components‘
is created, but never used by the designer. The overridden dispose-function
in the designer.cs frees all the objects in the componets-object but – as I
said – this object is never beeing used.
I customized all overrides of dispose() in the designer.cs:
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed;
otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && this.Controls != null)
{
this.components = new System.ComponentModel.Container();
foreach (Control o in this.Controls)
components.Add(o);
components.Dispose();
}
base.Dispose(disposing);
}
Now, most of the memory is freed but periodically there still remain some
fragments in the memory (>=4KB up to 64KB (?)).
I also noticed that running this application on a desktop pc with the “big“
:NET framework – no memoryloak persists!
Has anyone noticed the same behaviour and/or found a solution for it?
Does anyone have experience with applications running round the clock on
Windows CE / CF 2.0?
Are there bugs in the gc on compact framework?
Thanks for your help, best regards Chris