multitheftauto/mtasa-blue

engineReplaceModel memory leak & crash

Closed this issue · 0 comments

Describe the bug

When using engineReplaceModel very frequently, a memory leak occurs. This only affects vehicles, and the problem specifically lies with vehicle collisions. Depending on the file size, the memory leak happens sooner or later, until memory is overwritten and gta_sa.exe crashes at random offsets. I know the issue comes from the collision, because a vehicle without a collision does not cause a crash.

The bug does not occur with peds or objects, nor with vehicles without collisions, so the problem definitely concerns vehicle collisions, which are integrated inside the .dff file.

Bug found by TomeQmix.

Steps to reproduce

local dff = engineLoadDFF('11.dff')

local licz = 0
setTimer(function()
    for i = 1,5 do
        engineReplaceModel(dff, 411)

        licz = licz + 1
        setTimer(function(model_new2,dff2,txd2) 
            engineRestoreModel(411)
        end,100,1,model_new,dff,txd)
    end
    collectgarbage("collect")
    print(licz)
end,250,0)

Version

N/A

Additional context

Image

Relevant log output

Security Policy

  • I have read and understood the Security Policy and this issue is not security related.