A question regarding image caching.

When I tried to use a combination of show picture and wait to animate images, there was a flickering between them. I did some looking around and saw someone explain that it's because MV handles the process differently than ACE.

I was told this syntax would prevent that if I used it to call on the images before showing them, which worked.
ImageManager.loadPicture("imagename")

I'm speculating here, but if you kept a game running long enough, I imagine that if more images were cached it would cause the game to slow down? Is this the case?
If it is, is there script similar to 'ImageManager.loadPicture("imagename")' that I can use during events to clear any cached images I called specifically for that event?
You're right - MV caches the images (all the previous engines did as well), so the longer you play the game and the more images you show, the more memory will be used.


Something like this might let you selectively clear the images:


ImageManager.cache._inner[name].free();


where name is img/pictures/filename:hue and hue is 0 by default.


To be sure, you could probably type Object.keys(ImageManager.cache._inner) into the console to get a list of the keys, which would confirm or contradict the format above.
You're right - MV caches the images (all the previous engines did as well), so the longer you play the game and the more images you show, the more memory will be used.


Something like this might let you selectively clear the images:


ImageManager.cache._inner[name].free();


where name is img/pictures/filename:hue and hue is 0 by default.


To be sure, you could probably type Object.keys(ImageManager.cache._inner) into the console to get a list of the keys, which would confirm or contradict the format above.



I typed that into the console and most of it completed (up to "_inner") so I think you were right?
Just to make sure I get what you mean about the hue: If my image was called 'compass', the syntax would be "ImageManager.cache._inner[compass:0].free()"?
 
you left out the path, and the name, being text, should be in quotes.


ImageManager.cache._inner["img/pictures/compass:0"].free()


However, that's why I said to use Object.keys - so it would show you how to format them.  Please do that, because I haven't tested that syntax and can't guarantee that it's correct.

I typed that into the console and most of it completed (up to "_inner") so I think you were right?



It was the bit after _inner that I wasn't sure about, so please type the whole thing and press enter to see what it outputs to the console.
you left out the path, and the name, being text, should be in quotes.


ImageManager.cache._inner["img/pictures/compass:0"].free()


However, that's why I said to use Object.keys - so it would show you how to format them.  Please do that, because I haven't tested that syntax and can't guarantee that it's correct.


It was the bit after _inner that I wasn't sure about, so please type the whole thing and press enter to see what it outputs to the console.


Sorry, sorta misunderstood that. I get what you mean now.
You were pretty close, the only thing you were missing was the extension for the image before the hue.

Thank you very much for the help, and for inadvertently teaching me about the console.
the console is amazing if you want to get into any kind of scripting stuff 🙂

Original thread: https://forums.rpgmakerweb.com/threads/a-question-regarding-image-caching.72665/