Out of Memory Dialog with windows.forms.timer

G

Guest

Hello,

I wrote the Prg below for a SA-1110 Device with
Windows CE.Net 41 and .Net CF1.0 RTM = 1.0.2268.0

After a while I get the "Out-of-Memory"-Dialog of Windows CE and the System
hangs immediately.

The original Program is suppose to read data from an RS485 interface and
convert
it to bytes and send it over RS232 in 100ms intervals (perferable 10ms)
and after a while i'll get the Out of memory Dialog.
There might be more Problems in my PRg, but i pinned this one down
Anybody any suggestions what might be the Problem?
Unfortunatly i can't update the .Net CF since i don't have access to the CE
Image

cheers Olaf

using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;

namespace TestTimer
{

public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1;
private double dcounter1 = 0,
dcounter2 = 0,
dcounter3 = 0,
dcounter4 = 0,
dcounter5 = 0,
dcounter6 = 0,
dcounter7 = 0,
dcounter8 = 0,
dcounter9 = 0,
dcounter10 = 0,
dcounter11 = 0,
dcounter12 = 0
;
private System.Windows.Forms.TextBox txtMemory;
private string strTest = "";

public Form1()
{

InitializeComponent();

}

protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form-Designer Code

private void InitializeComponent()
{
this.timer1 = new System.Windows.Forms.Timer();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.txtMemory = new System.Windows.Forms.TextBox();
//
// timer1
//
this.timer1.Interval = 10;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(88, 112);
this.textBox1.ReadOnly = true;
this.textBox1.Size = new System.Drawing.Size(328, 20);
this.textBox1.Text = "";
//
// label1
//
this.label1.Location = new System.Drawing.Point(200, 72);
this.label1.Text = "Counter";
//
// txtMemory
//
this.txtMemory.Location = new System.Drawing.Point(456, 24);
this.txtMemory.ReadOnly = true;
this.txtMemory.Size = new System.Drawing.Size(152, 20);
this.txtMemory.Text = "";
//
// Form1
//
this.Controls.Add(this.txtMemory);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1);
this.Text = "Form1";
this.Load += new System.EventHandler(this.frmForm1_Load);

}
#endregion


static void Main()
{
Application.Run(new Form1());
}

private void frmForm1_Load(object sender, System.EventArgs e)
{
timer1.Enabled = true;
}

private void timer1_Tick(object sender, System.EventArgs e)
{
dcounter1++;
if(dcounter1 == 999999999999999)
{
dcounter1 = 0;
}
textBox1.Text = dcounter1.ToString("0000.00000");
strTest = "";
strTest =
"\x0002"
+dcounter1.ToString("0.00000")
+dcounter2.ToString("0.00000")
+dcounter3.ToString("0.00000")
+dcounter4.ToString("0.00000")
+dcounter5.ToString("0.00000")
+dcounter6.ToString("0.00000")
+dcounter7.ToString("0.00000")
+dcounter8.ToString("0.00000")
+dcounter9.ToString("0.00000")
+dcounter10.ToString("0.00000")
+dcounter11.ToString("0.00000")
+dcounter12.ToString("0.00000")
+"\x0003";

long lMemory = GC.GetTotalMemory(false);
txtMemory.Text = lMemory.ToString();

GC.Collect();
}
}
}
 

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