Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

How to identify what is consuming memory to reclaim it back

I solved my previous problem but now I have a subquestion. How can I identify what's using my memory so I can clean it.

For example these two methods:

Public List As New List(Of String)
Private Sub ReadList()
    Dim ListJSON As JArray = JArray.Parse(My.Resources.list) 'List in json format
    For Each item As JObject In ListJSON
        List.Add(item("name").ToString)
    Next
    ListJSON.RemoveAll()
    GC.Collect()
    GC.WaitForPendingFinalizers()
End Sub

Takes up 1GB before cleaning, takes 5s to complete. App is about 160MB in total after cleaning.


Public List As New List(Of String)
Private Sub ReadList()
   Dim TempStringHold As String() = My.Resources.list.Split({"""name"":"""}, StringSplitOptions.None)
   For Each StringSection In TempStringHold
       List.Add(StringSection.Substring(0, StringSection.IndexOf("""")))
   Next
   List.RemoveAt(0)
   Erase TempStringHold 
   GC.Collect()
   GC.WaitForPendingFinalizers()
End Sub

Takes up 0.5GB before cleaning, takes 1s to complete. App is about 210MB in total after cleaning.


I would like to get those 50MB back somehow in the faster version.

Comments