DragonBones / DragonBonesJS

DragonBones TypeScript / JavaScript Runtime
MIT License
746 stars 320 forks source link

call pendingDestroy when add image #117

Closed taoabc closed 5 years ago

taoabc commented 5 years ago

Call json.addToCache will call pendingDestroy internally, but add image to textureManager will not, so I call pendingDestroy manually.

akdcl commented 5 years ago

@jcyuan

jcyuan commented 5 years ago

👍 good catch, a potential bug of memory leak. but we can just use image.addToCache(); instead. the old code should be a legacy problem made when immigrating to the new db file plugin.

taoabc commented 5 years ago

I don't recommend add this image to cache because we already add image to textureManager, will become more heavier. What do you think? :grin:

jcyuan commented 5 years ago

image.addToCache, this action actually does 2 things: 1, add the loaded image into the textureManager belongs to the loader. (global to scene) 2, call pendingDestroy to prepare to delete the stuffs created when loading the images

only a diffenent between them is, addToCache detects to see if the image to be loaded has a normal map or not, if it does, add to cache too.

so actually they are the same, but use Phaser's API is more sensible because you don't knwo whether they will be changed in the furture or not, right?

taoabc commented 5 years ago

You're right, I've changed to addToCache

taoabc commented 5 years ago

Sorry for misunderstand your suggest, fixed and refresh output files at newest commit.

jcyuan commented 5 years ago

thanks for your effort @taoabc 👍