Resolved memory management issues for CFunction.#405
Conversation
Should not this be
It doesn't leak here, but don't get collected instantly. If you force a collection with
I can indeed reproduce the crash. It makes sense, since I trust that, as always, you did extensive testings but I will ask either way; did all contexts that were discussed into #344 been tested? Thanks, and welcome back, btw! :) |
Oh, my mistake, I must have mixed them up when I was switching the codes.
It is not a Test Code: def test():
for i in range(10000000):
get_chat_format = server[signature].make_function(
Convention.THISCALL, (
DataType.POINTER,
DataType.BOOL,
DataType.POINTER,
),
DataType.STRING,
)
get_chat_format.add_hook(HookType.PRE, func)
get_chat_format._delete_hook()
test()
I've passed the situations I can think of, and the code I usually work with, but are there any other situations that make you nervous? |
Nothing in particular, just wanted to confirm that issues for normal uses are not being re-introduced to fix problems related to manual hooks deletion. |
This addresses the problematic memory management issue for CFunction.
The specific bugs to be fixed this time are memory leaks and crashes, but I think the code is now easier to understand.
What complicated the issue was the lack of clarity on who was responsible for
CustomCallingConventionandNormalCallingConvention.Now,
CustomCallingConventionis managed by DynamicHooks or CFunction::DeleteHook, not by CFunction.For
NormalCallingConvention, DynamicHooks is normally responsible when hooked, CFunction::DeleteHook is responsible if CFunction is destroyed first, and CFunction is responsible if CFunction::DeleteHook is called first.Test Code: