-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C#: Avoid Dispose
until after every notification
#84013
base: master
Are you sure you want to change the base?
C#: Avoid Dispose
until after every notification
#84013
Conversation
Instead of disposing the C# instance when receiving `NOTIFICATION_PREDELETE` which may not be the last notification sent, we now assume the CSharpInstance destructor will always be called right before destroying the Object with the script and after every notification has already been sent. Also documents the flags in CSharpInstance that are somewhat related.
When exiting the game, this error is occasionally encountered. No other problems have been found.
|
Thanks for testing, I haven't been able to reproduce the error you mention but it doesn't sound surprising. It seems, since we are no longer disposing the scripts, some may remain after GDMono is freed. If that's the case, maybe #78157 would fix it. Can you test both PRs together and see if you can still reproduce the error? |
Okay, I'll test it in the next few days. |
After merging #78157, the previous error did not occur again. |
#83670 is approved, so we could go with that PR instead of this approach. |
Let's go with #83670 then, I think it's safer and we're too close to the 4.2 release. This PR may be the better solution long-term, but I think it needs to be tested more widely. |
Do we want to push this to 4.4 then, and find a good way to test reliably for potential memory issues? |
Instead of disposing the C# instance when receiving
NOTIFICATION_PREDELETE
which may not be the last notification sent, we now assume the CSharpInstance destructor will always be called right before destroying the Object with the script and after every notification has already been sent.tree_exited
/_ExitTree()
can't be found. #82279.NOTIFICATION_PREDELETE_CLEANUP
notification to fix C#Dispose()
#83670 that doesn't require adding a notification, but I feel like it's more risky