isfuturebright Posted February 21, 2014 Share Posted February 21, 2014 So we've been having some memory issues and after a lot of investigation trying to find leaks we ended up reaching the conclusion that there isn't any. We think the main problem is that our target platform (Samsung Smart TV) has a slow GC or something. So if we simply only load the assets for our game screen and start the game directly there it works without any lag. So we decided to try and load assets per screen, by doing: On every preload:preload: function(){ this.game.load.image('logo','assets/images/main_menu/logo_embaixadinhas.png'); this.game.load.image('menu_bg','assets/images/main_menu/mainmenu_front.jpg'); this.game.load.spritesheet('tinyCharMenu','assets/images/main_menu/soccer_menu.png', 144, 250);}On every shutdown:shutdown: function(){ this.removeCachedAssets();},removeCachedAssets: function(){ this.game.cache.removeImage("logo"); this.game.cache.removeImage("menu_bg"); this.game.cache.removeImage("tinyCharMenu");}Is this the right way to do this? I tried in on chrome and once I load them I can seem to remove them from the cache by doing this. Thanks, Link to comment Share on other sites More sharing options...
rich Posted February 22, 2014 Share Posted February 22, 2014 It will remove them from the cache for sure, but I cannot guarantee that means they will be gc'd (or when that will happen). If possible (I don't know how far along your game is) maybe you could try a quick test under the 1.2 version instead? As it has quite a lot lower memory overheads than 1.1. Link to comment Share on other sites More sharing options...
isfuturebright Posted February 24, 2014 Author Share Posted February 24, 2014 It will remove them from the cache for sure, but I cannot guarantee that means they will be gc'd (or when that will happen). If possible (I don't know how far along your game is) maybe you could try a quick test under the 1.2 version instead? As it has quite a lot lower memory overheads than 1.1. It's quite far into development really, but this problem is holding us back from releasing it so. I've been looking into 1.2 and a few things changed right? Sprites have no body anymore? My game is not physics heavy so if I'm able to do some simple square collision there won't be much problem porting. Also I saw that there's some new stuff like the image class that looks like something I'd use to spare some memory. How I'd get the sprite's width and make it collide with world bounds without the body?Thanks for the reply rich Link to comment Share on other sites More sharing options...
Recommended Posts