I'm a little confused how my heap memory usage is on a constant rise. I first increased my max heap memory but that isn't going to be a solution since there seems to be no stopping the usage. I attached a few images from VisualVM.
I wonder if the cause is all the JSON strings I'm downloading. My app constantly uses HttpJobs to get JSON strings and moves them to variable arrays like this:
I keep using the same string "GetMarkets" to fill the same Arrays from that string but somehow the heap memory keeps increasing. Is there a way to properly terminate a JSON string? Maybe the Arrays are holding on to past information somehow? Maybe the "job.GetString" never refreshes? I'm hoping someone sees a flaw in my method here. It's odd because the same code works from B4A on my phone for days without any issues.
I wonder if the cause is all the JSON strings I'm downloading. My app constantly uses HttpJobs to get JSON strings and moves them to variable arrays like this:
B4X:
Sub JobDone(job As HttpJob)
If job.Success = True Then
Select job.JobName
Case "job_GetMarkets"
GetMarkets = job.GetString
Get_Markets
End Select
job.Release
End If
End Sub
B4X:
Sub Get_Markets
Log(GetMarkets)
'Log("GetMarkets Length = " & sf.Len(GetMarkets) & " characters")
Dim Map1 As Map 'Success
JSON.Initialize(GetMarkets)
Map1 = JSON.NextObject
Log("Map1 = " & Map1)
Dim M As Map
Market_List.Clear
Market_List = Map1.Get("return")
For i = 0 To Market_List.Size-1
M = Market_List.Get(i)
GM_Last_Trade(i) = M.Get("last_trade")
GM_Market_ID(i) = M.Get("marketid")
GM_Primary_Coin(i) = M.Get("primary_currency_code")
GM_Secondary_Coin(i) = M.Get("secondary_currency_code")
GM_Low_Trade(i) = M.Get("low_trade")
GM_High_Trade(i) = M.Get("high_trade")
Next
End Sub
I keep using the same string "GetMarkets" to fill the same Arrays from that string but somehow the heap memory keeps increasing. Is there a way to properly terminate a JSON string? Maybe the Arrays are holding on to past information somehow? Maybe the "job.GetString" never refreshes? I'm hoping someone sees a flaw in my method here. It's odd because the same code works from B4A on my phone for days without any issues.
Last edited: