龙骨远程加载内存泄露问题一


龙骨远程加载内存泄露问题一

chrome工具发现ArmatureDisplay没有释放

  • 龙骨资源释放
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// 主要是armature泄露,导致armatureDisplay没有释放
let armature = this.m_armatureDisplay.armature();
if(armature){
dragonBones.WorldClock.clock.remove(armature);
armature.animation.stop();
armature.dispose();
armature = null;
}
// 下面释放可能并不影响,安全起见还是加上了
this.m_armatureDisplay.removeEventListener(dragonBones.EventObject.FADE_IN_COMPLETE, this.animationEventHandler, this);
this.m_armatureDisplay.removeEventListener(dragonBones.EventObject.COMPLETE, this.animationEventHandler, this);
this.m_armatureDisplay.removeEventListener(dragonBones.EventObject.FRAME_EVENT, this.frameEventHandler, this);
this.m_armatureDisplay.removeEventListener(dragonBones.EventObject.SOUND_EVENT, this.frameEventHandler, this);
if(this.m_armatureDisplay.node&&this.m_armatureDisplay.node.parent)
this.m_armatureDisplay.node.parent.removeChild(obj.m_armatureDisplay.node);
this.m_armatureDisplay = null;