I am plotting repeatedly data coming in via asyncsteamstext by calling "Sub createlinechart" when the complete data set has been received.
The Chart is plotted fine, but in each call of "createlinechart" the Java memory occupation is increased until the app runs very slow and finally stalls.
Maybe the cause could be the "InitializeNewInstance" that is called upon each call of this sub. I tried to move those initializations to the AppStart sub, but that results in an Java exception.
Is there a way to fix this?
B4X:
Sub createlineChart
If LCGetDataJO.IsInitialized Then LCGetDataJO.RunMethod("remove",Array As Object(SeriesJO))
SeriesJO.InitializeNewInstance("javafx.scene.chart.XYChart.Series",Null)
GetDataJO = SeriesJO.RunMethod("getData",Null)
For i=0 To 132
AddData(GetDataJO, i, test1(i))
Next
series2.InitializeNewInstance("javafx.scene.chart.XYChart.Series",Null)
GetDataJO=series2.RunMethod("getData",Null)
AddData(GetDataJO,Idxmin+4,ma)
AddData(GetDataJO,Idxmin+4,mi)
series1.InitializeNewInstance("javafx.scene.chart.XYChart.Series",Null)
GetDataJO=series1.RunMethod("getData",Null)
AddData(GetDataJO,Idxmax+4,ma)
AddData(GetDataJO,Idxmax+4,mi)
LCGetDataJO = LineChartJO.RunMethod("getData",Null)
'LCGetDataJO.RunMethod("add",Array As Object(SeriesJO))
LCGetDataJO.RunMethod("addAll",Array As Object(Array As Object(SeriesJO,series1,series2)))
End Sub
Maybe the cause could be the "InitializeNewInstance" that is called upon each call of this sub. I tried to move those initializations to the AppStart sub, but that results in an Java exception.
Is there a way to fix this?