You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was recently thinking about the lifetime of MVVM objects, and in the midst of that it brought me to wonder about my FluentAvalonia application which uses a main window Splash Screen.
Question:
Should AppWindow.SplashScreen resources be freed for Garbage Collection whenever the splash screen has completed showing? From profiling it, this shouldn't be an extremely wasteful issue but I see no need carrying references to a view / IApplicationSplashScreen that probably won't be ran again.
If so, is this an issue for FluentAvalonia or the upstream implementaton by WinUI (sidenote: Yay for the open sourcing of WinUI3)?
Assumptions about Garbage Collection:
For context, I literally learned about C# Garbage Collection roots minutes before drafting this discussion.
Since an implementation of AppWindow is part of the Avalonia.Application member ApplicationLifetime, I think it's easy to say that the Window's lifetime is tied to the Application's lifetime.
If that's the case, then we might deduce that any instantiated member of AppWindow shares a garbage collection root with Avalonia.Application - meaning it will exist for the life of the application.
The property IApplicationSplashScreen SplashScreen seems setup to remove references to the splash context if NULL is ever passed in. This is great - we can manually move SplashScreen resources to garbage collection by setting this property to NULL.
But conceivably, when would the developer find it appropriate to set it to null?
Because there are _splashContext operations occuring after the InitApp action delegate completes, clearly that isn't the answer.
Perhaps we need to set SplashScreen to null during a AppWindow / MainView lifecycle callback? However whenever I enter the DeveloperTools, the visual and logical trees both have my main view / main window views already laid out as the Splash Screen is running...
Nothing springs to mind to me based on the AppWindow.cs code.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I was recently thinking about the lifetime of MVVM objects, and in the midst of that it brought me to wonder about my FluentAvalonia application which uses a main window Splash Screen.
Question:
Should
AppWindow.SplashScreen
resources be freed for Garbage Collection whenever the splash screen has completed showing? From profiling it, this shouldn't be an extremely wasteful issue but I see no need carrying references to a view / IApplicationSplashScreen that probably won't be ran again.If so, is this an issue for FluentAvalonia or the upstream implementaton by WinUI (sidenote: Yay for the open sourcing of WinUI3)?
Assumptions about Garbage Collection:
For context, I literally learned about C# Garbage Collection roots minutes before drafting this discussion.
Since an implementation of
AppWindow
is part of theAvalonia.Application
memberApplicationLifetime
, I think it's easy to say that the Window's lifetime is tied to the Application's lifetime.If that's the case, then we might deduce that any instantiated member of AppWindow shares a garbage collection root with Avalonia.Application - meaning it will exist for the life of the application.
The property
IApplicationSplashScreen SplashScreen
seems setup to remove references to the splash context if NULL is ever passed in. This is great - we can manually move SplashScreen resources to garbage collection by setting this property to NULL.But conceivably, when would the developer find it appropriate to set it to null?
Nothing springs to mind to me based on the AppWindow.cs code.
Beta Was this translation helpful? Give feedback.
All reactions