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
but fixing this will break functionality that depend on caching HSCRIPT inputs (game event listeners, entity thinking, concommands). So this should not be fixed on its own without also changing how those are cached. Simply incrementing the ref count with sq_addref does not work.
A related invalid script-function-return-value leak exists in getVariant(), and it can be fixed in a similiar fashion (but with no complications like the previous one). While this fixes the underlying problem, to actually fix the leaks all script function calls with return values in C++ need to call ScriptVariant_t::Free() to free the invalid return values (string, vector, hscript).
This one exists in Valve's games as well. For example in CBaseEntity::ScriptThink() you can see the return value is not freed.
// leakplayer.SetContextThink("0",function(self){return self },0)// no leak
player.SetContextThink("1",function(self){returnVector()},0)
In both of these situations ref counts are incremented and SV_FREE flag is not set. I don't think adding ref does anything here either, everything seems to work fine without it. Am I missing something here, or is this design intended?
Describe the bug
HSCRIPT
parameters passed to native functions are not automatically released.Steps to reproduce
Watch the memory usage after calling functions with
HSCRIPT
parameters. The best example is an entity input.But functions where the input values are manually freed are fine.
Additional context
It is possible to fix this like so:
but fixing this will break functionality that depend on caching HSCRIPT inputs (game event listeners, entity thinking, concommands). So this should not be fixed on its own without also changing how those are cached. Simply incrementing the ref count with
sq_addref
does not work.A related invalid script-function-return-value leak exists in
getVariant()
, and it can be fixed in a similiar fashion (but with no complications like the previous one). While this fixes the underlying problem, to actually fix the leaks all script function calls with return values in C++ need to callScriptVariant_t::Free()
to free the invalid return values (string, vector, hscript).This one exists in Valve's games as well. For example in
CBaseEntity::ScriptThink()
you can see the return value is not freed.In both of these situations ref counts are incremented and
SV_FREE
flag is not set. I don't think adding ref does anything here either, everything seems to work fine without it. Am I missing something here, or is this design intended?See also: #104
The text was updated successfully, but these errors were encountered: