I'm looking at the the way ImageManager is implemented and it uses a cache to store objects. Example
ImageManager.loadNormalBitmap = function(path, hue) { var key = path + ':' + hue; if (!this._cache[key]) { var bitmap = Bitmap.load(path); bitmap.addLoadListener(function() { bitmap.rotateHue(hue); }); this._cache[key] = bitmap; } return this._cache[key];};Since this is meant to be the cache, it's meant to stay around for awhile.As you load images, they get cached.
At some point, if you load lots and lots of images, you're going to end up using a lot of memory.
I'm sure eventually you're going to run into problems?
I don't know if audio or other resources have a similar issue since I haven't looked at those yet.
I've been wondering about this myself. Especially considering mobile devices can run into memory problems quite easily.
You are probably right. Though, I've noticed many programs don't seem to care about memory allocation anymore, as they think everyone has all the memory in the world, so why bother?
And that is also why I find I now have to close and restart my internet browsers about every 4 hours, else they are using up 500K memory easy.
I suppose if you wanted to implement a cache-collection system, you should be able to implement a timer that loops through the cache periodically, say maybe once per ten seconds, but probably longer, maybe only on map/scene change, go through each item, while maintaining a list of the last time each file was accessed by aliasing the load functions and storing Date objects in a list for each filename. If the last time a file was accessed is greater than a defined threshold, destroy the cached copy.
Now, the method I just described is a bit of a dumb method. It doesn't know the amount of memory available, how much it's necessarily using (though you can easily calculate that by checking the length and width of each image as you loop through, multiply them together, and then multiply by 4 for total bytes of memory used (mult by 4 because each color is rgba)), nor how much i sbeing requested. One possible way you might be able to get information on how much is available and how much is used is through chrome://memory-internals/, which has a little 'update' button that will check chrome's memory usage, and then have a JSON representation available in a small textbox, as well as displaying it on the screen. If you can find a way to press the button pragmatically and then grab the JSON output, you should be able to compare available memory to used memory and remove files accordingly. However, in this case you'll have to keep in mind that this will only work on the chrome web browser, the desktop clients, and maybe android ports. Other browsers and iOS would have to be switched to 'dumb' mode.
But if you have any other ideas, I'm interested in hearing them, as creating a 'dumb mode' cache cleaner wouldn't be hard at all.
Guys, Its worse than that. Removing _cache wont help at all, because you have to manually free them from webgl context.
when you use goto, woudn't the gc actually release the objects ?
The scene is not stored anymore anywere...
But yes, they should have freed resources anyway
Interesting topic, I will have to keep this in mind in the future when my project gets bigger...
in AIR I controlled use of memory with dispose method, I'm sure in MV there is a way to control that, since there are no hidden classes, and one way or another you can "dispose/destroy" or w/e term they use here...
or maybe the game already has some kind of cache limit which auto-cleans itself above a certain threshold?
They probably won't have a github account.
Most of them don't want/need one.
But as I told you before, you should try to make other people write as less as they can, and they only use between scenes Bitmaps and Audio files...
Hmm, looks like this would mess with my popup plugins. But i thought about switching to an observer pattern, anyway.
I already encounter out of memory issues on smart phones and tablets. My game is pretty small, just a few small rooms and one big overworld map. Both use Firefox browsers (couldn't get it to run on Chrome-based browsers.) The crash usually happens when switching maps.
Large games with many resources shouldn't be a problem in itself. Many Android / iOS games are huge, sometimes up to a 1 GB. And they don't crash or get out of memory issues even after hours of play. My simple RMMV game crashes after a few map transfers. So you guys are right. It's either RPG Maker's map handling or WebGL's limitations.