Pool objects created when passing objects from generated assemblies to the user#92
Conversation
Kasuromi
left a comment
There was a problem hiding this comment.
Looks good, this has been something on our radar for a while.
Unfortunately since this all relies on the GarbageCollector::RunFinalizer hook, we need to be able to reliably fetch the method on x86/x64. I suggest looking for a way to fetch the method through xref traversal or grabbing one or two more signatures for x64 games.
Il2CppInterop.Runtime/Injection/Hooks/GarbageCollector_RunFinalizer_Patch.cs
Show resolved
Hide resolved
|
Could we get this PR merged soon? 😃 |
|
AFAIK this is ready to go, lmk if changes are required |
Il2CppInterop.Runtime/Injection/Hooks/GarbageCollector_RunFinalizer_Patch.cs
Show resolved
Hide resolved
|
I have made the changes, Some of the objects remain in the cache as their finalizer doesnt run, but forcing the GC to run tends to remove a chunk of them so I don't think it is much of an issue |
This comment was marked as spam.
This comment was marked as spam.
Kasuromi
left a comment
There was a problem hiding this comment.
With this current implementation, if the GarbageCollector::RunFinalizer method doesn't get resolved (e.g. signatures return zero) Il2CppInterop will throw an exception for passing a null method and will then pass on this null pointer into the detouring API.
In the case of BepInEx an assertion in Dobby is hit, but the runtime will generally continue.
@js6pak suggested here that Il2CppInterop should print a warning and disable pooling when it's unable to resolve the method. If that's feasible it'll be best to implement to ensure backwards compatibility with other games that for one reason or another we can't fetch this method for.
|
Is there anything that still needs to be done before merging this pull request? I have a mod release that is waiting on these changes. 😊 |
…mblies to the user (BepInEx#92)" This reverts commit 876e0f0.
This essentially stops the massive memory usage which occurs as a result of creating a brand new wrapper object every time you call a method/field/property from any of the generated assemblies.