Using Scout I can see that as I dispose of my textureCache the GPU memory is not being released.
Would anyone have an idea as to why thsi is happening?
I have a list of 10 item renderers, each of which has it's own horizontal list which has 50 items(imageLoaders).
Each of the horizontal lists load in the same 50 images.
So in total I am loading 500 images.
Each of the image loaders has the same _scrollableImagesTextureCache assigned as the textureCache.
_imageLoader.textureCache = Main.galleryScreen._scrollableImagesTextureCache;
_imageLoader.textureSmoothing = TextureSmoothing.BILINEAR;
//Main.galleryScreen
public var _scrollableImagesTextureCache:TextureCache;
_scrollableImagesTextureCache = new TextureCache(50);
Once all images have been loaded the GPU is at 363,000KB.
(note that if I don't use textureCache the GPU usage at this point is exactly the same).
If I don't use textureCache and dispose of the list of 10 renderers, the GPU usage drops to 17,000KB.
But when using textureCache, when I dispose of the lists and textureCache the GPU memory only drops to 327,000KB.
These are the functions I'm using to dispose of the list and textureCache.
//within the imageLoader listItemRenderers
public function destroy():void {
this.removeEventListener(starling.events.Event.REMOVED_FROM_STAGE, destroy);
try{
removeChild(_imageLoader, true);
_imageLoader = null;
} catch(e:Error) {
}
// the itemRenderers in the main list of 10 items contain these functions:
public function destroy():void {
this.removeEventListener(starling.events.Event.REMOVED_FROM_STAGE, destroy);
clearList();
_dataObject = null;
}
private function clearList():void {
_list.removeEventListener(FeathersEventType.RENDERER_ADD, renderedAdded);
_list.removeEventListener(FeathersEventType.RENDERER_REMOVE, renderedRemoved);
_list.removeEventListener(feathers.events.FeathersEventType.SCROLL_COMPLETE, list_scrollHandler);
removeChild(_list, true);
_list = null;
_listLayout = null;
_renderer = null;
_listCollection = null;
}
And then to remove the list containing the 10 items:
private function transitionOutCompleteHandler( event:Event ):void {
destroyRenderers();
}
private function destroyRenderers():void {
if (_items) {
if (_items.length > 0) {
for (var i:int = 0; i < _items.length; i++) {
trace("GALLERY destroyRenderer");
SlammerListItemRenderer(_list.itemToItemRenderer(_items[i])).destroy();
}
}
}
//remove the thumbnails
clearList();
clearTextureCache();
}
private function clearList():void {
_list.removeEventListener(starling.events.Event.UPDATE, list_updateHandler);
_list.removeEventListener(FeathersEventType.RENDERER_ADD, rendererAdded);
_pullView.removeEventListener(FeathersEventType.PULLING, pullView_pullingHandler);
removeChild(_list, true);
_vl = null;
_renderer = null;
_items.length = 0;
_items = null;
_listCollection = null;
_list = null;
}
private function clearTextureCache():void {
trace("_scrollableImagesTextureCache.maxUnretainedTextures",_scrollableImagesTextureCache.maxUnretainedTextures);
for (var i:int = 0; i < _scrollableImagesTextureCache.maxUnretainedTextures; i++) {
trace("_scrollableImagesTextureCache.hasTexture", _scrollableImagesTextureCache.hasTexture("https://www.propertytours.tv/movies/imageStore/9405_125518781/L_125518781_"+i+"_512.jpg")); //true
trace("_scrollableImagesTextureCache.getRetainCount", _scrollableImagesTextureCache.getRetainCount("https://www.propertytours.tv/movies/imageStore/9405_125518781/L_125518781_"+i+"_512.jpg")); //0
}
_scrollableImagesTextureCache.dispose();
for (var i:int = 0; i < _scrollableImagesTextureCache.maxUnretainedTextures; i++) {
trace("_scrollableImagesTextureCache.hasTexture", _scrollableImagesTextureCache.hasTexture("https://www.propertytours.tv/movies/imageStore/9405_125518781/L_125518781_"+i+"_512.jpg")); //false
trace("_scrollableImagesTextureCache.getRetainCount", _scrollableImagesTextureCache.getRetainCount("https://www.propertytours.tv/movies/imageStore/9405_125518781/L_125518781_"+i+"_512.jpg")); //0
}
_scrollableImagesTextureCache = null;
trace("_scrollableImagesTextureCache", _scrollableImagesTextureCache); //blank
}