Timer Memory

  • Thread starter Thread starter wg
  • Start date Start date
W

wg

Can someone help me with this. I have a application in which a timer runs
all the time. I set some flags in side the timer so there is nothing inside
to cause a problem. However if I run the app, it continually grows in
memory. If I leave it long enough it will eventually grow out of control How
can I deal with this?

Thanks

wg
 
WG,

I probably don't understand you. Do you mean that your program is running
all the time inside one method.

That is one of the exceptions where I have seen that you than have to call
the Garbage Collector yourself time by time.

Cor
 
wg,

Can you be more specific? Better yet, can you post a short, but
complete program that demonstrates the problem?

What flags are you setting? What timer are you using? What else are
you doing inside in the timer event and elsewhere in the program?

Brian
 
Here is a mockup of my applicaiton. Notice that I have commented out the
thread that I was starting and the problem still occurs. If the progarm is
run, I can watch it in the task manager and it continues to grow in memory.
The flags are being set by a serial port routine. I have tried a system
timer and form timer, same result. I attempted the System.GC.Collect at the
end of the Tick Event, same result. No matter what I have tried, same
result.


Public Class Form1

Inherits System.Windows.Forms.Form

Dim counter As Int16

Dim TxFlag As Boolean

Dim RxFlag As Boolean

Dim RxCommFlag As Boolean

Dim TxCommFlag As Boolean




Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Timer1.Enabled = True

End Sub



Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick

'Dim Tx As New Thread(AddressOf sendcomm)

If TxFlag And RxCommFlag Then

TxFlag = False

RxCommFlag = False

counter = 0

End If

If Not TxFlag And Not RxCommFlag Then

TxFlag = True

'Tx.Start()

End If

If TxFlag And Not RxCommFlag Then

counter = counter + 1

End If

If counter > 200 Then

TxFlag = False

RxCommFlag = False

counter = 0

End If



End Sub
 
Well, I certainly don't see anything obvious from the code you've
posted. How much memory growth are we talking about and in what time
frame? Do you have an estimate in MB/hour or equivalent units? Have
you eliminated the serial communications and other aspects of the
application as possibilities?

Brian
 

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

Back
Top