feat: improve garbage collection for injected types & implement finalizer support & stop leaking memory where we can avoid it.
- New way to track instances of injected classes, allowing injected finalizers to run properly, and fix the memory leaks which the documentation warns of.
- Consolidate Il2CppObjectBase initialization (and related IL generation) into one cohesive method.
- See the new documentation for the procedural overview.
- This also fixes a bug/is a breaking change: the lifetime of managed injected instances is now shorter, meaning that non-injected fields might now be dropped earlier than expected.~
- Open question: currently, this PR has some trickery to make the managed object's finalizer itself (
~Foo()) be the method which is overriden, should we instead make this somepublic override void Il2CppFinalize()dummy method instead? It likely would make our implementation burden a little easier, and maybe elide theSuppressFinalizetrickery, but would be an ergonomics hit.
Hello 👋
I don't normally work on runtime stuff, so I'm not sure I feel comfortable reviewing your pull request, but it did not go unnoticed.
FYI I'm currently working on the v2 rewrite, which could cause issues for your pull request. I'm looking at getting an implementation for the generation changes pushed soon.
exciting! could you point me to your work (if available online, no worries if not) so i can see how we intersect?
exciting! could you point me to your work (if available online, no worries if not) so i can see how we intersect?
Not yet available. I'm going to make a pull request when I push.
exciting! could you point me to your work (if available online, no worries if not) so i can see how we intersect?
https://github.com/ds5678/Il2CppInterop/tree/v2-rewrite
i'm a little confused on what the roadmap is with v2. is there an issue or something which lays it out? as a downstream user, i need to know if v2 is "coming soon" or not; are we at that stage of saying "nothing gets merged until v2 because that's top priority"? if so, i can rebase on top of your branch, but if not, i'm also willing to rebase yours on mine once this is merged.
i want to make this as easy a merge as possible for you.
i'm a little confused on what the roadmap is with v2. is there an issue or something which lays it out?
There's a milestone, which includes most of the v2 changes.
as a downstream user, i need to know if v2 is "coming soon" or not
Yes, I'm making a WIP pull request sometime this week.
are we at that stage of saying "nothing gets merged until v2 because that's top priority"?
Yes, that will likely be the next merge. 1.5.1 was released as the "last commit before the massively breaking changes of v2."
if so, i can rebase on top of your branch, but if not, i'm also willing to rebase yours on mine once this is merged.
i want to make this as easy a merge as possible for you.
I still need to:
- Rebase my branch on the recent commits from 1.5.1
- Make some generation changes
- Tidy up my branch
- Make a pull request
At that point, my branch will still need additional runtime changes, but it'll be safe for you to rebase your changes and make a pull request onto my branch.
thank you so much.