I have a program that I run in the background that freezes after running for a day or two.
I have not been able to track down the cause of the freeze and am wondering if there is a
memory leak. My knowledge of ‘Instruments’ is less than rudimentary but I believe both it
and Activity Monitor show increasing memory use.
Here is a simple example.
Set up a window with a Listbox and Timer and set the Timer to Run Mode - Multiple every 2 seconds.
Place the following code in the Timer Run event:
Listbox1.RemoveAllRows
For i As Integer = 0 To 10
Listbox1.AddRow Str(i)
Next
Run the program. Memory use seems to continually increase but I am not sure I’m on the right track.
Can anyone confirm whether this is normal or shows a leak before I submit a feedback report?
I don’t see a memory leak with the code you posted.
What exactly do you see in Instruments? It should tell you something about leaked objects and then you need to dig into those objects.
Activity Viewer shows the total memory used including memory fragmentation. That’s different from what Instruments shows. Instruments is your best bet to find out what is causing the memory leak.
example to track object count with a shared property.
example
Sub Open() Handles Open
Var a As New Class1
Var b As New Class1
'should be 2
System.DebugLog(Class1.Count.ToString)
a = Nil
b = Nil
'should be 0
System.DebugLog(Class1.Count.ToString)
End Sub
Class1
Public Shared Property Count as Integer = 0
Public Sub Constructor()
Class1.Count = Class1.Count + 1
End Sub
Public Sub Destructor()
Class1.Count = Class1.Count - 1
End Sub
Would a tutorial for Instruments be helpful? I’m not an expert but I get by. This week I had some fun with a bug where my app got slower and slower after a while. With Instruments I was able to see that the MBS SQLite plugin made the problem.
What I noticed when I tried to use Instruments/Leaks was the All Heap & Synonymous VM and All Heap Allocations & Transient continue to increase. I don’t know if that’s indicative of a problem or memory leak but since I’m at the limit of my Instruments knowledge I thought I’d see if anyone else considered this normal.