从3.0.0开始测试到3.3.1的版本,使用一个龙骨5.5版本的动画文件,不管是把场景设置为自释放或者是手动释放动态加载的龙骨动画,在安卓设备上都存在内存泄露情况,重复调用加 载释放,或者是场景间不断的切换,内存一直增长无法回收,单个龙骨动画反复操作内存能增长到500M以上,这个问题如何解决?
@ccclass(“MainScene”)
export class MainScene extends Component{
bundle;
prefab;
fish
onBtnClick(event, custom){
if(custom == "add"){
this.onEnable()
}else if(custom == "del"){
this.onDestroy()
}else{
director.loadScene("test")
}
sys.garbageCollect()
}
onEnable(){
assetManager.loadBundle("pre", (err, bundle)=>{
if(!err){
this.bundle = bundle
this.bundle.load("anabariliusAlburnops", (err, asset)=>{
if(!err){
this.prefab = asset
this.fish = instantiate(asset)
this.fish.parent = this.node
}
})
}
})
}
onDestroy(){
if(this.fish){
this.fish.destroy()
this.fish = null
}
if(this.prefab){
assetManager.releaseAsset(this.prefab)
this.prefab = null
this.bundle.releaseAll()
assetManager.removeBundle(this.bundle)
this.bundle = null
}
}
}