You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This Issue is about a bug in the Phaser.Cache API 2.7.3 and below.
In method Phaser.Cache#destroy
/** * Clears the cache. Removes every local cache object reference. * If an object in the cache has a `destroy` method it will also be called. * * @method Phaser.Cache#destroy */
destroy: function(){// ...}
The unexpected behaviour is that most objects that are put in the cache are wrapped in another object, without a destroy method.
For example, looking at BitmapData, which has a `destroy' method:
addBitmapData stores the actual data in a new object with keys data and frameData
getBitmapData relies on getItem to get the correct data from the cache
destroy does not take the property into account as getItem does and therefore does not invoke destroy on the data and frameData objects.
As a result, in this case, canvasses are never returned to the CanvasPool, causing a memory leak when loading external image data and relying on the cache to clean up old images.
Suggested solution:
Update the destroy method to also iterate over the properties in the stored cache object. If a property contains a destroy method, invoke it on the property as well.
The text was updated successfully, but these errors were encountered:
This makes a huge difference. The retained object size in our scenario is reduced to 1/10th of the amount used without the change, mainly due to the canvas pool being cleared correctly now.
This Issue is about a bug in the Phaser.Cache API 2.7.3 and below.
In method
Phaser.Cache#destroy
The unexpected behaviour is that most objects that are put in the cache are wrapped in another object, without a
destroy
method.For example, looking at
BitmapData
, which has a `destroy' method:addBitmapData
stores the actual data in a new object with keysdata
andframeData
getBitmapData
relies ongetItem
to get the correct data from the cachedestroy
does not take the property into account asgetItem
does and therefore does not invokedestroy
on thedata
andframeData
objects.As a result, in this case, canvasses are never returned to the
CanvasPool
, causing a memory leak when loading external image data and relying on the cache to clean up old images.Suggested solution:
destroy
method, invoke it on the property as well.The text was updated successfully, but these errors were encountered: