Jump to content

Recommended Posts

Posted

VB.Net code

Public Class Form1

Public aTimer As System.Timers.Timer

Public Sub Main()

Dim test As Object = CreateObject("AutoItX3.Control")

End Sub

Public Sub Start()

aTimer = New System.Timers.Timer

AddHandler aTimer.Elapsed, AddressOf OnTimer

aTimer.Interval = 2500

aTimer.Enabled = True

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Start()

End Sub

Public Sub OnTimer(ByVal source As Object, ByVal e As Timers.ElapsedEventArgs)

Main() 'fill WH & PK arrays

End Sub

End Class

When i executed the following code, my compiled exe constantly grows 4K each time the timer is executed. Apperently, .net garbage collection does not work on unmanaged code? If I replace this line:

Dim test As Object = CreateObject("AutoItX3.Control")

with this:

Dim test As integer = 0

the problem is solved. Thus, it is fair to say that I am constantly creating AutoItX3 type objects and the memory is not be reassigned after the sub routine finishes execution. I am not sure how I should fix this problem. Any ideas? thx!

Posted

VB.Net code

Public Class Form1

Public aTimer As System.Timers.Timer

Public Sub Main()

Dim test As Object = CreateObject("AutoItX3.Control")

End Sub

Public Sub Start()

aTimer = New System.Timers.Timer

AddHandler aTimer.Elapsed, AddressOf OnTimer

aTimer.Interval = 2500

aTimer.Enabled = True

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Start()

End Sub

Public Sub OnTimer(ByVal source As Object, ByVal e As Timers.ElapsedEventArgs)

Main() 'fill WH & PK arrays

End Sub

End Class

When i executed the following code, my compiled exe constantly grows 4K each time the timer is executed. Apperently, .net garbage collection does not work on unmanaged code? If I replace this line:

Dim test As Object = CreateObject("AutoItX3.Control")

with this:

Dim test As integer = 0

the problem is solved. Thus, it is fair to say that I am constantly creating AutoItX3 type objects and the memory is not be reassigned after the sub routine finishes execution. I am not sure how I should fix this problem. Any ideas? thx!

I was able to solve the problem by doing this:

Public oAutoIt = CreateObject("AutoItX3.Control")

CODE GOES HERE...

oAutoIt = Nothing

  • 2 weeks later...
Posted

I was able to solve the problem by doing this:

Public oAutoIt = CreateObject("AutoItX3.Control")

CODE GOES HERE...

oAutoIt = Nothing

May I also suggest this:

Public oAutoIt as New AutoItX3Lib.AutoItX3

Wouldnt you prefer early binding and the intellisense support!?!?!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...