Reputation: 263
My app is a document-based Xamarin.mac app that uses WKWebView to display HTML content generated in-code. Each time a new window is created, 2 new processes are also created: 'APP_NAME Networking' and 'about:'. However, when the window is closed, the two processes remain. Open 10 windows, close 10 windows, and I have 20 orphaned processes.
Does anyone have any ideas for how to make these go away when the window is closed?
(EDIT) Please note that these are not orphaned objects/data structures, but independently running system processes that are owned by the app, but not by the document window/view controller that spawned them. Quit the app, the child processes die. But close the window, and the child processes live on...
Upvotes: 1
Views: 71
Reputation: 9990
Memory management in .NET is based on the garbage collection. As such it is indeterminate from the point of app or developer. Meaning that things like above are not unexpected in .NET.
In Xamarin there is the additional problem - Xamarin is keeping reference on native resources, but it has no idea what those resources are and how much computer resources they take, so the automatic garbage collection is frequently not happening when you expect it.
It is suggested that you should Dispose
the important native resources that you don't need. I would definitely consider WKWebView among such resources.
Other than that you may also initiate garbage collection manually, but that is not recommended unless really needed.
Upvotes: 1