Skip to content

engineReplaceModel memory leak & crash #4348

@FileEX

Description

@FileEX

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions