Thrain Posted March 3, 2006 Posted March 3, 2006 VB.Net codePublic 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 SubEnd ClassWhen 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 = 0the 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!
Thrain Posted March 3, 2006 Author Posted March 3, 2006 VB.Net codePublic 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 SubEnd ClassWhen 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 = 0the 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
jvetter713 Posted March 13, 2006 Posted March 13, 2006 I was able to solve the problem by doing this:Public oAutoIt = CreateObject("AutoItX3.Control")CODE GOES HERE...oAutoIt = NothingMay I also suggest this:Public oAutoIt as New AutoItX3Lib.AutoItX3Wouldnt you prefer early binding and the intellisense support!?!?!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now