No memory release for UViewController when variable is initialized

VS, C# latest beta

Had not idea how to name title properly, but this piece of code will explain all. If variable is initialized in class directly, then UIViewController memory is not released when view is popped out and dealloc is not called. Any new push view called cause memory grown. Best to add mapview to view, to reproduce

namespace myNameSpace
{
    [IBObject]
    public class test: UIViewController
    {
        private bool myBoolVariable; // this is okay
        private bool myBoolVariable2 = true; // this cause no memory release
        
        public override void viewDidLoad()
        {
            base.viewDidLoad();

            return;
        }

        
        public override void didReceiveMemoryWarning()
        {
            base.didReceiveMemoryWarning();

            // Dispose of any resources that can be recreated.
        }
    }
}

[EDIT]

Same problem if variable is declared as readonly

private readonly long Btn_on  = 0xFF3F3D3E;

workaround (but can be modified):

private static long Btn_on  = 0xFF3F3D3E;

b.r.

Thanks, logged as bugs://72928

Can you send us a full project that shows this, including the context the class is used in (i.e. how it is created and goes to of scope)?

Ughh, oka will make new project. Example was from my main project. Give me some time, because I must answer on few posts here and remind/check things :smile:

[EDIT]

Here is

memNoRelease.zip (119.5 KB)

To reproduce:

Run app, click “show map”, click back button and check console for “map released” message (may take few sec).
Uncomment one of problematic variables with comment “// this cause no memory release” and repeat all. This time dealloc is not called and if You will use instruments, You will see that every “show map” increase memory.
After ~10 clicks to show map with uncommented line console print “Received memory warning.” and after ~20 times app crash.

b.r.

bugs://72928 got closed with status fixed.

1 Like

Perfect. Will check soon when will back to iOS project programming.

b.r.