From fe7646b6dd2466792143abc9302802c0d06b78fd Mon Sep 17 00:00:00 2001 From: CacheFlowe Date: Sun, 16 Feb 2014 20:56:32 -0700 Subject: [PATCH] Fix PIXI.Texture.removeTextureFromCache() Fixes a couple of issues: * Cached textures should also be removed from PIXI.BaseTextureCache to be fully removed. This was discussed here: http://www.html5gamedevs.com/topic/2182-pixi-web-app-slows-down-after-loading-20mb-of-images-on-ipad-mini2/?p=14945 * Base64-encoded images use the full base64 string as the hash key (rather than a much smaller image URL string for "normal" texture loading). This essentially doubles the browser memory usage for each cached image. Previously, when setting the value as null, the key remained, leaving an image worth of data still in the TextureCache. This fix is essential if loading & clearing lots of base64-encoded images. --- src/pixi/textures/Texture.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pixi/textures/Texture.js b/src/pixi/textures/Texture.js index 2025b7e..8500a6e 100644 --- a/src/pixi/textures/Texture.js +++ b/src/pixi/textures/Texture.js @@ -230,7 +230,8 @@ PIXI.Texture.addTextureToCache = function(texture, id) PIXI.Texture.removeTextureFromCache = function(id) { var texture = PIXI.TextureCache[id]; - PIXI.TextureCache[id] = null; + delete PIXI.TextureCache[id]; + delete PIXI.BaseTextureCache[id]; return texture; };