Memory saved by fragment

When I call popBackStack like:

 manager.popBackStack("mybackstack", FragmentManager.POP_BACK_STACK_INCLUSIVE); 

will the memory stored by fragments belonging to "mybackstack" be freed?

I have a FragmentActivity that manages a ListFragment . Each time I click on an item, FragmentActivity creates a new Fragment that shows some information about the item that was clicked, and then shows a DialogFragment with a bitmap (which I recycle when the dialog is rejected). I put android:configChanges="orientation" in the manifest and override onConfigurationChanged as needed.

+4
source share
1 answer

Yes, the memory stored by the fragments will be freed. From the documentation,

public static final int POP_BACK_STACK_INCLUSIVE

Flag for popBackStack (String, int) and popBackStack (int, int): If set, and the name or identifier of the back stack has been provided, then all matching entries will be consumed until one that does not match is found, or the bottom of the stack reaches . Otherwise, all entries prior to but not including this entry will be deleted.

and

public abstract void popBackStack (String name, int flags)

Pull the last fragment transition from the stack of the back of the manager fragment. If there is nothing to do, false is returned. This function is asynchronous - it calls a pop request, but the action will not be performed until the application returns to the event loop.

Please note, however, that there is no guarantee that this memory will be freed immediately.

+1
source

All Articles