[] Array cause memory leak on iOS

(James Esword) #1

IDE: VS 2015
Target (If relevant): iOS

Found this problem by my unit tests after upgrade from to

iOSTest.zip (106.2 KB)

public class TestObj {
    public override void dealloc() {
        // will never be called
        Foundation.NSLog("TestObj dealloc!!!");

[UIApplicationMain, IBObject]
class AppDelegate : IUIApplicationDelegate {
    public UIWindow window { get; set; }

    public BOOL application(UIApplication application) didFinishLaunchingWithOptions(NSDictionary launchOptions) {
        window = new UIWindow(UIScreen.mainScreen().bounds);
        window.rootViewController = new UIViewController withNibName(null) bundle(null);

        // No strong ref will be kept
        var a = new TestObj[] {new TestObj()};
        a = null;

        return true;

(RemObjects) #2

Thanks, logged as bugs://75686

(RemObjects) #3

bugs://75686 got closed with status fixed.

(Carlo Kok) #4

Just retested this: properly deallocates now.