I am having real trouble figuring out how to release memory, I know you can run a GC.Collect(), and that this can run and is managed on it own in xamarin.. however..
My problem is how to let Xamarin know that something is allowed to be collected/ or freed or if possible remove it directly.
Consider a XAML page with this Root Element:
<Grid x:Name="ContentGrid">
</Grid>
At run time we dynamically add to the ContentGrid the following children (a ScrollView to ContengGrid and a Grid to the ScrollView)
ContentGrid ->ScrollView -> ScrollGrid
Then the ScrollGrid has has its columns dynamically added.. say in a little loop. say we add 12 columns of a certain fixed width
ContentGrid ->ScrollView -> ScrollGrid(with 12 fixed width columns)
As we create each column we add a image to the ScrollGrid
ContentGrid ->ScrollView -> ScrollGrid(with 12 fixed width columns and 1 image per column)
This renders as a nice little scrolling view of images and works. BUT I wish to know how to free up memory afterwards, because right now these things tend to live in the app seemingly forever..
Example 1 - We want to remove the 12 images and add a new set of images - How to remove / clear the 12 images and 12 columns from memory? - say the next set of images only has 3 images, so we want to get to 3 columns, and 3 images (having completely freed up the original 12)
Example 2 - We want to navigate away from this entirely (still keeping ContentGrid as the root), we wish to de-allocate all dynamically added content and get back to the state of an empty ContentGrid. (before presumably adding new controls to the ContentGrid for another purpose entirely)
Please try to answer the 2 example scenarios.
thanks.
--think I have answered my own question here...
Children.Remove(child) ...