I need some guidance on trying to resolve my out of memory error issue.
I have a gauge class that creates a "gauge" using 5 transparent panels, each panel the same size and "stacked" on top of the previous to create layers that hold unique info for each gauge (e.g. frame, ticks, numbers, etc). each panel has a canvas used to draw on that panel. these panels are added to a base panel to create the total gauge display (i.e. one unique gauge). so basically 6 panels per gauge.
in the activity to display the gauges there is a main panel using a scrollview2d. on this main panel i add gauges in this type of fashion. so the scrollview can hold several gauges at once.
(so in this instance i would have a scrollview with 3 gauges on it, with each gauge utilizing 6 panels and 5 canvases.)
the sub displaylayout can be called multiple times based on a spinner from which the user can display their layout preference.
i have no problem displaying the layout the first time. however, based on the complexity of the layout (and corresponding memory required) i often have OOM errors when trying to display a new layout.
so is there a better way to minimize memory? does each panel require its own canvas or should i use a global canvas and just assign it to a panel when i need to update the specific panel layer. at what point in time is the lion's share of memory consumed, e.g. when the canvas is initialized to a panel?
I have a gauge class that creates a "gauge" using 5 transparent panels, each panel the same size and "stacked" on top of the previous to create layers that hold unique info for each gauge (e.g. frame, ticks, numbers, etc). each panel has a canvas used to draw on that panel. these panels are added to a base panel to create the total gauge display (i.e. one unique gauge). so basically 6 panels per gauge.
in the activity to display the gauges there is a main panel using a scrollview2d. on this main panel i add gauges in this type of fashion. so the scrollview can hold several gauges at once.
B4X:
sub displaylayout
mainpanel.removeallviews
dim gauge1,gauge2,gauge3 as clsgauge
gauge1.type = "digital"
gauge2.type = "analog"
gauge3.type = "digital"
mainpanel.addview(gauge1, x, y, w, h) etc etc
mainpanel.addview(gauge2, x, y, w, h) etc etc
mainpanel.addview(gauge3, x, y, w, h) .....
end sub
(so in this instance i would have a scrollview with 3 gauges on it, with each gauge utilizing 6 panels and 5 canvases.)
the sub displaylayout can be called multiple times based on a spinner from which the user can display their layout preference.
i have no problem displaying the layout the first time. however, based on the complexity of the layout (and corresponding memory required) i often have OOM errors when trying to display a new layout.
so is there a better way to minimize memory? does each panel require its own canvas or should i use a global canvas and just assign it to a panel when i need to update the specific panel layer. at what point in time is the lion's share of memory consumed, e.g. when the canvas is initialized to a panel?