source-sdk-2013 icon indicating copy to clipboard operation
source-sdk-2013 copied to clipboard

Fix memory leak from unreleased script variants

Open ficool2 opened this issue 11 months ago • 0 comments

Various VScript-related routines are leaking memory due to not releasing script variants. This is due to either failing to call g_pScriptVM->ReleaseValue or anything that called g_pScriptVM->SetValue with a temporary object. Notable functions affected are TraceHull, TraceLineEx, EmitSoundEx and OnTakeDamage hook. This has been observed to cause issues with servers running out of memory when hosting maps that called these functions repeatedly in scripts.

This PR addresses the issue by calling ReleaseValue where appropriate, adding an overload to SetValue that automatically releases temporary objects, and releasing values in the Get helper.

ficool2 avatar Feb 20 '25 01:02 ficool2