Cache Manager

Cache Manager
2015.11.30
by Shaz

Introduction
This plugin allows you to clear your image cache when changing maps, in order to reduce memory usage, especially on mobile devices. The tradeoff is that images being removed from the cache may result in more loading delays as they have to be reloaded.

How to use
Add to your plugins folder (file name should be CacheManager.js).
Set plugin parameters based on whether you only want to clear the cache on mobile devices, or all platforms. I strongly recommend you do not clear the system image cache.

If you set Clear All to Y, you don't have to set any of the remaining parameters.
If you set Clear All to N, and you have plugins that use custom img/ folders, add those to the Custom Images parameter at the bottom if you wish to have those images cleared from cache on map change as well. The format should be:

img/folder1; img/folder2; img/folder3 name; img/folder4(include the img/ folder, and separate by semi-colon ; )

Plugin
Download from pastebin

Credit
- Shaz

Terms
- free for use in commercial games
ooo this looks nice! Have you thought about making it so you can assign different maps a "Region" via note tag or something, and if two maps are of the same region then do not clear the cache as to reduce loading times between similar maps of an area?
No, I was just after the most simple solution that would remove the crashing issue on mobile devices, and cater for other plugins that require their own image folders.

It's certainly not the most elegant solution, but to make it really nice would require a lot of rewriting of core scripts, and I'm just not up for that 😉
wow this looks so great, I have been worrying about the memory use a lot. nice stuff I will give it a try

saw another plugin for reading jpg is png is not present, I hope this could solve some performance issues...
Nice, I saw that conversation going on about this problem in another thread glad to know someone's already fixed the issue, good job shaz I'll test once I figure out porting to mobiles.
It's not a perfect solution. Let us know how well it does work for you though 🙂
Hey Shaz is it possible for me to put this in the options menu so the player can manually clear the cache?
Hi Shaz,


Do the audio files consume cache in the same way? I have noticed that running game through Game.exe shows 4 processes (same name but different memory use) in the task manager. Based on how the memo use is growing I was guessing one of them is for audio. Is it possible to add a function in this plugin to clear cache for audio as well?(if that is the case)


Thanks~
@YunoYukiAkise you could do that, but it would need some modificiation.


@doranikofu I don't think audio files are cached.
Hi Shaz, In RMMV 1.3.0 Devs has added classes called CacheMap and CacheEntry and It has also changed some code of ImageManager class. So I think that your plugin will also need to be updating for RMMV 1.3.1
Does it still work on 1.6.1?
did you try it and see?
Hi there!
In your code:
Code:
var params = PluginManager.parameters('CacheManager');
Does that mean that i have to rename the file to CacheManager.js ?
How to use
Add to your plugins folder (file name should be CacheManager.js).
Sorry! Its a bite to late in Brazil 😅
Thanks!
A bit late to the party, but: It should work on 1.6.1, but I'm not entirely sure if there's a point to using it. The community basic plugin allows you to set the max amount of pixels that will be cached. Once they reach this number, pictures from oldest cached will be removed from cache. So for mobile devices you can keep this number at 10mio pixels while for PC you can up it to 100 mio pixels, no need to clear the entire cache and slow down your game.

Not to mention the browser has its own cache we can't touch that serves to speed up loading as well.
A bit late to the party, but: It should work on 1.6.1, but I'm not entirely sure if there's a point to using it. The community basic plugin allows you to set the max amount of pixels that will be cached. Once they reach this number, pictures from oldest cached will be removed from cache. So for mobile devices you can keep this number at 10mio pixels while for PC you can up it to 100 mio pixels, no need to clear the entire cache and slow down your game.

Not to mention the browser has its own cache we can't touch that serves to speed up loading as well.
@Poryg Only now i see your answer! Sorry!
But thanks a lot!! I came here to tell that this plugin is not work anymore (unless i have misunderstanding how it works).

I'v made a project to test it, and i made two maps. In one of them i put a lot of pictures. Then i use the Debug Reporty Memory plugin to check the use of cache and the cached size.

Spoiler: Debug report memory
de6E5Bg.png

So when i transfer to the other map, in this event i erase the pictures.
The used size cache has reduced (it always change when i go to other maps)
But the cached size still remais the same number (it never change when i go to other maps).
I also make another tests with the tutorial game and made a lot of maps and watch the cached size. But it stills the same number and going up.
When you say "Once they reach this number, pictures from oldest cached will be removed from cache."
How can i monitor this? In the usedSize or in the cachedsize? I put the limit to 40, so when its (the usedSize or cachedSize?) reaches this number it will be deleted?
How can i monitor this? In the usedSize or in the cachedsize? I put the limit to 40, so when its (the usedSize or cachedSize?) reaches this number it will be deleted?
In the cached size.
Used size counts how much is being used in megabytes. And if it's less than cached size, it's only good, because it means it doesn't need to load anything new and just uses resources stored in the memory.
Once cachedSize reaches X, in your case 40 million pixels, it will start to delete images from the oldest cached to free up some space in the cache to store more images. This is exactly why using Shaz's plugin is pointless even if it works, because it's automated now.
It's always good if the used size is less than the cached size. Because that means the game is loading very little resources and can run more smoothly.
Yeah, honestly, if you're using the later versions of MV where they added cache cleanup, don't use this plugin. It was helpful 3 years ago, but if the engine does it by default now, just stick with that.
In the cached size.
Used size counts how much is being used in megabytes. And if it's less than cached size, it's only good, because it means it doesn't need to load anything new and just uses resources stored in the memory.
Once cachedSize reaches X, in your case 40 million pixels, it will start to delete images from the oldest cached to free up some space in the cache to store more images. This is exactly why using Shaz's plugin is pointless even if it works, because it's automated now.
It's always good if the used size is less than the cached size. Because that means the game is loading very little resources and can run more smoothly.

Understood! Thanks a lot!

Yeah, honestly, if you're using the later versions of MV where they added cache cleanup, don't use this plugin. It was helpful 3 years ago, but if the engine does it by default now, just stick with that.

Oh, i see! Thanks for the answer!

Original thread: https://forums.rpgmakerweb.com/threads/cache-manager.51868/