[LayaAir 2.0]开关页面导致内存一直增长
优化资源的时候遇到一个内存增长的问题,ui面板通过“加载资源,实例化,放入ui管理器”的流程进行管理,实例化一次就会一直存在,至于打开和关闭是从舞台移除添加来实现的,最近发现如果不处理资源释放的问题内存会越滚越大,所以我在ui从舞台移除的时候进行了清理,大多数的放用的方法是”
Laya.Loader.clearTextureRes(url);
比如这个页面的关闭
Close(): void {
IconManager.Instance().clearTexture(this.leftverticaldrawing.skin);//清理某个动态贴图的资源(clearRes方法清理png)
IconManager.Instance().clearTexture(this.rightverticaldrawing.skin);
ResMgr.ins.clearTextureImg(WindowNpc.ResList);//clearTextureRes方法清理atlas
}
这个页面的资源
static ResList: Array<Object> = [
{ url: "npc.json", type: Laya.Loader.JSON },
{ url: "packatlas/uiatlasnew/talk.atlas", type: Laya.Loader.ATLAS }
];
通过直接加载数组的形式
“通过这种方式清理资源发现每次“打开关闭”一个面板之后gpuM会比之前增长2M左右,反复的“打开关闭”会越来越大
Laya.Loader.clearTextureRes(url);
比如这个页面的关闭
Close(): void {
IconManager.Instance().clearTexture(this.leftverticaldrawing.skin);//清理某个动态贴图的资源(clearRes方法清理png)
IconManager.Instance().clearTexture(this.rightverticaldrawing.skin);
ResMgr.ins.clearTextureImg(WindowNpc.ResList);//clearTextureRes方法清理atlas
}
这个页面的资源
static ResList: Array<Object> = [
{ url: "npc.json", type: Laya.Loader.JSON },
{ url: "packatlas/uiatlasnew/talk.atlas", type: Laya.Loader.ATLAS }
];
通过直接加载数组的形式
“通过这种方式清理资源发现每次“打开关闭”一个面板之后gpuM会比之前增长2M左右,反复的“打开关闭”会越来越大
没有找到相关结果
已邀请:
要回复问题请先登录
2 个回复
Laya_XS
赞同来自:
AlanDeng
赞同来自: