How to "release" images from memory

In my iOS project, I have quite a few custom table cells with MobileImageViewers. When I load these custom table cells to a data source of a iOSMobileTable and assign pictures to these MobileImageViewers (the pictures are PNG files dragged onto the project), I do it with this code:
var f as FolderItem = SpecialFolder.resource("picture1.png")
var p as picture = picture.open(f)
imgPic1.image = p

It all works fine but when I close the view with that table, the images seem to stay in memory. I’m thinking it’s because the PNG files are global and I have created a reference to them. Is that true? If so, how can I release them from memory when closing the view? Setting the table’ data source to nil doesn’t work.

Thank you, Happy Easter and stay safe!

How do you know it stays in memory?

Watching the memory allocation in Instruments, it goes up from 20 to 120 MB when I open the screen with the table, but it stays at roughly 116 when I close that screen.

Edit: sorry, I said “view” in my original post but it’s on API 2 so it’s a MobileScreen.

Did you see my blog entry?

https://www.mbs-plugins.de/archive/2021-02-15/Understanding_Memory_Statistic/monkeybreadsoftware_blog_xojo

First of all, Images in iOS are loaded dynamically as needed, and will be reallocated when all instances go out of scope.

Now, if you’re making custom row cells, iOS keeps one or more rows in memory in the background so the next time you need it, it’ll be available so lists scroll smoothly… and each time you “create” one iOS looks at the list of previously created rows and if it doesn’t find an unused match, creates a new one.

I noticed that too in 2019r3. I haven’t tested yet in 2021r1.
Opening and closing multiple times the same view used up to 20MB more each time, slowly growing to more than 200-300MB used in total.

I will try again soon with the latest version of Xojo.