Hello,
in a xamarin forms (android/ios) app i have a timer like this:
Device.StartTimer(TimeSpan.FromSeconds(User.Refresh), () => { Task.Factory.StartNew(async () => { var http = new Services(Helpers.Settings.IP, Helpers.Settings.UserName, Helpers.Settings.Password); var data = await http.RT(User.Devices); Device.BeginInvokeOnMainThread(() => { // UI }); }); return true; });
The class services make a request with HttpClient:
var request = new HttpRequestMessage() { RequestUri = new Uri(string.Format(Const.API_GET_DATA, ip)), Method = HttpMethod.Post }; var content = JsonConvert.SerializeObject(devices, new JsonSerializerSettings() { Formatting = Formatting.None }); request.Content = new StringContent(content, Encoding.UTF8, "application/json"); request.Headers.Add(Const.HEADER_USERNAME, username); request.Headers.Add(Const.HEADER_PASSWORD, password); var response = await client.SendAsync(request); content = await response.Content.ReadAsStringAsync(); return JsonConvert.DeserializeObject<getDataResponse>(content);
Thant run every 1 second, it get a json object and refresh an UI. It work for little more than 300/350 second and than crash with this:
referenceTable GDEF length=814 1
referenceTable GSUB length=11364 1
referenceTable GPOS length=47302 1
referenceTable head length=54 1
referenceTable GDEF length=808 1
referenceTable GSUB length=11364 1
referenceTable GPOS length=47320 1
referenceTable head length=54 1
10-11 11:22:18.941 F/art (26295): art/runtime/indirect_reference_table.cc:127] JNI ERROR (app bug): local reference table overflow (max=512)
10-11 11:22:18.941 F/art (26295): art/runtime/indirect_reference_table.cc:127] local reference table dump:
10-11 11:22:18.941 F/art (26295): art/runtime/indirect_reference_table.cc:127] Last 10 entries (of 511):
10-11 11:22:18.941 F/art (26295): art/runtime/indirect_reference_table.cc:127] 510: 0x7114d938 java.lang.Class<java.security.cert.X509Certificate>
10-11 11:22:18.941 F/art (26295): art/runtime/indirect_reference_table.cc:127] 509: 0x12e67e40 com.android.org.conscrypt.OpenSSLX509Certificate
10-11 11:22:18.941 F/art (26295): art/runtime/indirect_reference_table.cc:127] 508: 0x12e23380 mono.android.runtime.InputStreamAdapter
10-11 11:22:18.941 F/art (26295): art/runtime/indirect_reference_table.cc:127] 507: 0x12e40f00 java.lang.String "PKIX"
10-11 11:22:18.941 F/art (26295): art/runtime/indirect_reference_table.cc:127] 506: 0x12e14b30 java.security.cert.X509Certificate[] (1 elements)
10-11 11:22:18.941 F/art (26295): art/runtime/indirect_reference_table.cc:127] 505: 0x12e0ee60 java.lang.String "PKIX"
10-11 11:22:18.941 F/art (26295): art/runtime/indirect_reference_table.cc:127] 504: 0x12dec440 java.security.cert.X509Certificate[] (1 elements)
10-11 11:22:18.941 F/art (26295): art/runtime/indirect_reference_table.cc:127] 503: 0x12de4480 java.lang.String "PKIX"
10-11 11:22:18.941 F/art (26295): art/runtime/indirect_reference_table.cc:127] 502: 0x12ccbf90 java.security.cert.X509Certificate[] (1 elements)
10-11 11:22:18.941 F/art (26295): art/runtime/indirect_reference_table.cc:127] 501: 0x12cce080 java.lang.String "PKIX"
10-11 11:22:18.941 F/art (26295): art/runtime/indirect_reference_table.cc:127] Summary:
10-11 11:22:18.941 F/art (26295): art/runtime/indirect_reference_table.cc:127] 1 of mono.android.runtime.InputStreamAdapter
10-11 11:22:18.941 F/art (26295): art/runtime/indirect_reference_table.cc:127] 1 of java.lang.Class
10-11 11:22:18.941 F/art (26295): art/runtime/indirect_reference_table.cc:127] 254 of java.lang.String (254 unique instances)
10-11 11:22:18.941 F/art (26295): art/runtime/indirect_reference_table.cc:127] 254 of java.security.cert.X509Certificate[] (1 elements) (254 unique instances)
10-11 11:22:18.941 F/art (26295): art/runtime/indirect_reference_table.cc:127] 1 of com.android.org.conscrypt.OpenSSLX509Certificate
10-11 11:22:18.941 F/art (26295): art/runtime/indirect_reference_table.cc:127]
10-11 11:22:19.081 F/art (26295): art/runtime/barrier.cc:90] Check failed: count_ == 0 (count_=-1, 0=0) Attempted to destroy barrier with non zero count
10-11 11:22:19.081 F/art (26295): art/runtime/runtime.cc:366] Runtime aborting --- recursively, so no thread-specific detail!
10-11 11:22:19.081 F/art (26295): art/runtime/runtime.cc:366]
10-11 11:22:19.081 F/libc (26295): Fatal signal 6 (SIGABRT), code -6 in tid 26369 (Thread-13261)
Any idea why?
Thanks
Answers
try profiling your app and finding memory leaks - if any
Hello,
do you mean with this: https://developer.xamarin.com/releases/profiler/preview/?
I deleted the use of Device.StartTimer and started a task, inside a while cycle with a sleep do a similar job, but with no crash. I suspect that is a leack as you mentioned.
Thanks for interests.