RenderTexture显卡内存泄漏的bug

做这个问题时发现的:
https://forum.cocos.org/t/topic/145023

在游戏里需要动态修改图片,所以使用renderTexture,每次都是1024x1024。
由于修改的图片会被复用,所以每次都是new RenderTexture,经过若干次操作后,在chrome的任务管理器,gpu进程中发现占用的内存越来越大,拖死了chrome;在iOS手机里,最后也是闪退。

    let renderTex = new RenderTexture();
    renderTex.reset({
          width:1024, height:1024
    });

    this.m_camera.node.active = true;
    this.m_camera.orthoHeight = 512;
    this.m_camera.targetTexture = renderTex;

    // director.root?.pipeline.render([this.m_camera.camera]);
    director.root?.frameMove(0);

    let sp = new SpriteFrame();
    sp.texture = renderTex;
    this.m_dstImage.spriteFrame = sp;

    this.m_camera.targetTexture = null;
    this.m_camera.node.active = false;
    this.m_srcImage.spriteFrame = null;

在chrome里,可以用renderTex.destroy()来解决这个问题,但是iOS不行。
所以问题是,rendertexture应该怎么使用和清理呢?

最后使用了一个renderTexture数组,每次都按下标递增复用来解决的

1赞

后来解决了吗