Skip to content

Memory leak, temporary textures not deleting #3977

@W3lac3

Description

@W3lac3

Describe the bug

Currently the MTA, when we use the dxDrawImage or dxDrawImageSection functions it will create a temporary texture, however this texture is not being deleted when it is not in use. This results in high memory consumption.

A solution that I believe is viable for this system would be to create a timer that will validate if that texture has not been used for X amount of time. If it is unused, the system will automatically delete the texture, freeing up memory.

Steps to reproduce

Create an image render using the dxDrawImage or dxDrawImageSection functions. Then disable the render, using the getElementsByType function you can see that the total number of textures has increased, but even if you don't use it, it won't go down. Below is the example code:

local tick = 0

function render()
    local now = getTickCount()

    if (now - tick >= 1000) then
        return removeEventHandler("onClientRender", root, render)
    end

    dxDrawImage(0, 0, 100, 100, "assets/image.png", 0, 0, 0, tocolor(255, 255, 255, 255))
end

addCommandHandler("textures", function()
    print("Total textures:", #getElementsByType("texture", resourceRoot))
end)

addEventHandler("onClientRender", root, render)

Version

Client: v1.6-release-22894 (Windows 11, 64-bit)
Server: v1.6-release-22894 (Windows 11, 64-bit)

Additional context

No response

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

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions