Prevent Duplicate Window Instance

Well, it works as you expect (and which frankly makes sense) on my Fusion Windows 11 VM. So I’ll check with one of my Linux VMs, and maybe an older macOS version or two.

1 Like

If it works in previous macOS but only not in Sonoma, we need to open an Issue report ASAP (Sonoma will break current working software).

If the behavior differs in some macOS versions, it will need a report too. That’s a path for huge errors and leaks no one should expect.

It is not Sonoma-specific. The same issue occurred on my Monterey guest. Meanwhile, as with Windows, proper behavior was had on Gentoo Linux (my “if it will work here, it will work anywhere” distro. :slight_smile: )

I shall whip up an example and file a ticket.

Edit: if it is an Apple bug, it goes back at least to Catalina.

1 Like

I’m inclined to think that it is a Xojo bug, because it is in the Xojo memory management engine VS WeakRefs. Once Xojo frees some object, even if the OS don’t release immediately that block of the memory, Xojo should fire the destructors for it and nullify the weakrefs pointing to such released object right away. That space was marked to be recalled by the OS, immediately or deferred, but that’s another parallel task we should not care about. The Xojo MM released it, the events should be fired and work as expected, and the Xojo engine would be ok.

I found my mistake. I had made the sharedInstance property public (i.e, didn’t override the default.) Now all is peachy. Note again that Windows and Linux did not care about this.

Interesting, I would assume that it should not cause that retention, as it did not in your Windows and Linux, TBH, I don’t know why just publicizing that private property in the class without touching it would cause this lock (unless you touched it :smile:). But I now assume it’s ok anyway if following the original design. :wink:

Well, not in my “real” project, it isn’t. The change only affected the example. I’ll be darned if I know why.

Future Jerry: I know why. My projects have Touch Bar support via EinhugurMacOSBridge. It is THAT instance, not the WeakRef, which I have to proactively nullify when I close the window(s). :stuck_out_tongue: