activity.loadlayout question

HotShoe

Well-Known Member
Licensed User
Longtime User
When I do an activity.loadlayout() in a sub, does this load a new instance of the layout each time that sub is called? Or does the routine know it is already loaded and just make the current layout active. I'm still trying to understand memory usage in b4a and the best ways to handle it.

Currently, I use panels for most layouts and simply set them to visible or not and sendtoback or bringtofront.

Thanks,

--- Jem
 

stevel05

Expert
Licensed User
Longtime User
As I understand it, calling activity.loadlayout will just load it again, leaving the old references available for garbage collection.

It will slow down the app as it takes time to load especially if the layout is large. You can check if the layout is loaded by calling isinitialized on any of the views it contains and load it if it returns false.
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
As I understand it, calling activity.loadlayout will just load it again, leaving the old references available for garbage collection.
Since the old layout views are on the Activity, they will still be referenced, so I dont think they will be garbage collected. You will need to remove views from the Activity first.
 
Upvote 0

HotShoe

Well-Known Member
Licensed User
Longtime User
Thanks, that was my impression, but I needed to get a definitive answer.

--- Jem
 
Upvote 0
Top