COCO引擎调试面板 GFX Texture Mem值并不准确

GFX Texture Mem 值是 cc.gfx.deviceManager.gfxDevice.memoryStatus.textureSize,该值在 创建 Texture2D时会增加,但是当Texture2D 失去引用,自动被js回收器回收时,该值不会更新变小。

比如:

var ff = “http://www.www.www.png
cc.assetManager.loadRemote(ff, (error, img) => {
var dd = cc.SpriteFrame.createWithImage(img);
var node = new cc.Node();
var sp = node.addComponent(cc.Sprite);
sp.spriteFrame = dd;
window.img = node;
})
cc.gfx.deviceManager.gfxDevice.memoryStatus.textureSize 会变大

再设置 window.img = null; dd对象没有被引用了,dd是会被系统回收的,但是 textureSize就再也不会变小了。 除非手动 调用 cc.assetManager.releaseAsset(dd)释放内存 textureSize 才会变小。
因此 对象置空其实js是会回收的,但在引擎这个规则下为了维护 textureSize 的正确性,还得手动调用releaseAsset去释放,这样反而复杂化了。

1赞