T Tom_707 Member Licensed User Nov 4, 2020 #1 Which of these alternatives is the most efficient in terms of memory management? 1. Continually re-using the same View: B4X: Copy Dim SCView As ScrollView Dim lblTemp As Label For Counter = 0 to 10000000 SCView.Panel.AddView(lblTemp,....) . . . lblTemp.RemoveView Next 2. Creating a new instance of the View every time: B4X: Copy Dim SCView As ScrollView For Counter = 0 to 10000000 Dim lblTemp As Label SCView.Panel.AddView(lblTemp,....) . . . lblTemp.RemoveView Next 3. Creating a new instance of the View and releasing the memory used by the previous instance. Is this even necessary? What command/ syntax is correct? B4X: Copy Dim SCView As ScrollView For Counter = 0 to 10000000 Dim lblTemp As Label SCView.Panel.AddView(lblTemp,....) . . . lblTemp.RemoveView lblTemp = Null '*Does this release an object?*' Next
Which of these alternatives is the most efficient in terms of memory management? 1. Continually re-using the same View: B4X: Copy Dim SCView As ScrollView Dim lblTemp As Label For Counter = 0 to 10000000 SCView.Panel.AddView(lblTemp,....) . . . lblTemp.RemoveView Next 2. Creating a new instance of the View every time: B4X: Copy Dim SCView As ScrollView For Counter = 0 to 10000000 Dim lblTemp As Label SCView.Panel.AddView(lblTemp,....) . . . lblTemp.RemoveView Next 3. Creating a new instance of the View and releasing the memory used by the previous instance. Is this even necessary? What command/ syntax is correct? B4X: Copy Dim SCView As ScrollView For Counter = 0 to 10000000 Dim lblTemp As Label SCView.Panel.AddView(lblTemp,....) . . . lblTemp.RemoveView lblTemp = Null '*Does this release an object?*' Next
Erel B4X founder Staff member Licensed User Longtime User Nov 4, 2020 #2 Tom_707 said: Which of these alternatives is the most efficient in terms of memory management? Click to expand... Use xCustomListView with lazy loading. If you really want to show million items then rethink your design. No user will ever want to scroll a list with million items. If you want to show 50k items and think that it is a good idea then use PreoptimizedCLV. Upvote 0
Tom_707 said: Which of these alternatives is the most efficient in terms of memory management? Click to expand... Use xCustomListView with lazy loading. If you really want to show million items then rethink your design. No user will ever want to scroll a list with million items. If you want to show 50k items and think that it is a good idea then use PreoptimizedCLV.
T Tom_707 Member Licensed User Nov 4, 2020 #3 Erel said: Use xCustomListView with lazy loading. If you really want to show million items then rethink your design. No user will ever want to scroll a list with million items. If you want to show 50k items and think that it is a good idea then use PreoptimizedCLV. Click to expand... I'm not trying to create a list with a million items. The ScrollView is there just as an example. Replace ScrollView with a Panel. And the million is there to try and convey that I have a really large loop where I am using and re-using a huge amount of Views. I would like to know what is the most memory efficient way of doing this. Upvote 0
Erel said: Use xCustomListView with lazy loading. If you really want to show million items then rethink your design. No user will ever want to scroll a list with million items. If you want to show 50k items and think that it is a good idea then use PreoptimizedCLV. Click to expand... I'm not trying to create a list with a million items. The ScrollView is there just as an example. Replace ScrollView with a Panel. And the million is there to try and convey that I have a really large loop where I am using and re-using a huge amount of Views. I would like to know what is the most memory efficient way of doing this.
Erel B4X founder Staff member Licensed User Longtime User Nov 4, 2020 #4 Reuse the views. Don't add views that are not currently visible. Upvote 0
eps Expert Licensed User Longtime User Nov 4, 2020 #5 Reuse. It seems contradictory but Mobile programming prefers this approach. Upvote 0
AnandGupta Expert Licensed User Longtime User Nov 4, 2020 #6 In short use PreoptimizedCLV if you can. It is memory efficient. Regards, Anand Upvote 0
T Tom_707 Member Licensed User Nov 5, 2020 #7 Erel said: Reuse the views. Don't add views that are not currently visible. Click to expand... Thanks Erel. eps said: Reuse. It seems contradictory but Mobile programming prefers this approach. Click to expand... Thanks eps. Upvote 0
Erel said: Reuse the views. Don't add views that are not currently visible. Click to expand... Thanks Erel. eps said: Reuse. It seems contradictory but Mobile programming prefers this approach. Click to expand... Thanks eps.
T Tom_707 Member Licensed User Nov 5, 2020 #8 AnandGupta said: In short use PreoptimizedCLV if you can. It is memory efficient. Regards, Anand Click to expand... Thanks Anand. Upvote 0
AnandGupta said: In short use PreoptimizedCLV if you can. It is memory efficient. Regards, Anand Click to expand... Thanks Anand.