Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Is caching a memory leak?

Tsukihime

Praised Adventurer
Xy$
0.00
RPG Maker implements caching to speed up image loading.
If you look at the ImageManager, you can see it in action

Code:
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];
};
However, I don't believe this cache is ever cleared out.
Will this become a problem?
 

eivl

Local Hero
Xy$
0.00
JavaScript:
ImageManager.clear = function() {
    this._cache = {};
};
Is the clear cache method never called?
 

eivl

Local Hero
Xy$
0.00
JavaScript:
ImageManager.loadBitmap = function(folder, filename, hue, smooth) {
    if (filename) {
        var path = folder + encodeURIComponent(filename) + '.png';
        var bitmap = this.loadNormalBitmap(path, hue || 0);
        bitmap.smooth = smooth;
        this.clear();
        return bitmap;
    } else {
        return this.loadEmptyBitmap();
    }
};
i think you can test this, not sure how far ImageManager goes.
 
Top