Hi
I developed a program that runs on an industrial device with Android, it works fine.
If I enable these lines of code after a few hours the memory used increases from 30 to about 40 Mega and the application runs very slowly as if it was locked.
Else the server is not running, then the sub active are:
Sub TimerEth_Tick (raised every two seconds)
Sub SendObject
If I disable The TimerEth, the App work well for days.
Android 4.1
I developed a program that runs on an industrial device with Android, it works fine.
If I enable these lines of code after a few hours the memory used increases from 30 to about 40 Mega and the application runs very slowly as if it was locked.
Else the server is not running, then the sub active are:
Sub TimerEth_Tick (raised every two seconds)
Sub SendObject
B4X:
#Region ETHERNET
Sub TimerEth_Tick
TimerEth.Enabled = False
Dim val As Int
Dim mapeth As Map
mapeth.Initialize
mapeth.Put("ip", myip)
mapeth.Put("format1", format1str)
mapeth.Put("format2", format2str)
mapeth.Put("format", format)
mapeth.Put("locked", lock)
mapeth.Put("operator", op)
mapeth.Put("lastmem", mem)
mapeth.Put("oramem", oramem)
mapeth.Put("media", media)
SendObject(mapeth)
countsendeth = countsendeth + 1
If countsendeth > 4 Then
countsendeth = 0
format1lb.Text = ""
format2lb.Text = ""
operatorlb.Text = ""
operator = ""
format = 0
mina = 0
maxa = 0
img1.Visible = False
img2.Visible = False
img3.Visible = False
bar1.Visible = False
bar2.Visible = False
bar3.Visible = False
conn = False
arrowlb.Visible = False
End If
TimerEth.Enabled = True
End Sub
Sub SendObject (Obj As Object)
Dim raf As RandomAccessFile
raf.Initialize(File.DirInternal, "temp", False)
raf.WriteB4XObject(Obj, 0)'raf.WriteObject(Obj, True, 0)
Dim size As Int = raf.CurrentPosition
Dim data(size) As Byte
raf.CurrentPosition = 0
Do While raf.CurrentPosition < size
raf.ReadBytes(data, raf.CurrentPosition, size - raf.CurrentPosition, raf.CurrentPosition)
Loop
Dim j As HttpJob
j.Initialize("send object", Me)
j.PostBytes(linkserv, data)
raf.Flush 'added but not needed
raf.Close 'added but not needed
j.Release 'added but not needed
If File.Exists(File.DirInternal, "temp") = True Then File.Delete(File.DirInternal, "temp") 'added but not needed
End Sub
Sub ReadObject (In As InputStream) As Object
Try
Dim out As OutputStream
out.InitializeToBytesArray(0)
File.Copy2(In, out)
Dim raf2 As RandomAccessFile
raf2.Initialize3(out.ToBytesArray, False)
Dim res As Object = raf2.ReadB4XObject(0) 'raf2.ReadObject(0)
raf2.Flush
raf2.Close
Return res
Catch As Exception
End Try
End Sub
Sub JobDone(j As HttpJob)
Dim ricaricaval As Boolean
If j.Success Then
Dim result As Map
result.Initialize
result = ReadObject(j.GetInputStream)
If result.IsInitialized = False Then
j.Release
Return
End If
mapresult = result
Else
'Log("Error: " & j.ErrorMessage)
End If
j.Release
End Sub
#End Region
If I disable The TimerEth, the App work well for days.
Android 4.1