Android Question Correct memory management for Dialogs

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Hi
I am C/C++/C# programmer, mostly C/C++, and therefore not so expert in Java. Maybe I miss something very basic. My question is basically related to what happens to memory when I repeatedtly use a Dialog, opening and closing it during App execution. The question is: shall I remove the views from the Dialog, after closing it, to free memory? Let's consider the following example code, which works (for now), where a Dialog contains various Views, which are loaded from various Layouts.
B4X:
sub Globals
    Private MyTabHost As TabHost
    Private MyDialog As B4XDialog
    Dim MyPanel As B4XView
end sub

private Sub ShowDialog
    
    If Not (MyPanel.IsInitialized) Then MyPanel= xui.CreatePanel("")
    
    MyPanel.SetLayoutAnimated(0, 0, 0, Activity.Width,Activity.Height-40dip)
            
    MyPanel.LoadLayout("Layout_0")
            
    MyTabHost.AddTab("Tab_1/","Layout_1")
    MyTabHost.AddTab("Tab_2/","Layout_2")

    MyDialog.Initialize(Activity)
    MyDialog.Title="....."
        
    'populate MyDialog views
                
    Wait For (MyDialog.ShowCustom(MyPanel, "OK", "", "CANCEL")) Complete (Resu As Int)
        
    If Resu = xui.DialogResponse_Positive Then
       ' retrieve Data from MyDialog
    end if
End Sub

Thanks in advance.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…