Cache Manager

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,618
Reaction score
13,212
First Language
English
Primarily Uses
RMMV
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
 
Last edited by a moderator:

Kaliya

// Caffeine Overload
Developer
Joined
Nov 1, 2015
Messages
506
Reaction score
566
First Language
English
Primarily Uses
RMMV
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?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,618
Reaction score
13,212
First Language
English
Primarily Uses
RMMV
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 ;)
 

doranikofu

Veteran
Veteran
Joined
Oct 4, 2015
Messages
113
Reaction score
31
First Language
Chinese
Primarily Uses
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...
 

Fox536

Veteran
Veteran
Joined
Nov 5, 2015
Messages
173
Reaction score
60
Primarily Uses
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.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,618
Reaction score
13,212
First Language
English
Primarily Uses
RMMV
It's not a perfect solution. Let us know how well it does work for you though :)
 

YunoYukiAkise

Villager
Member
Joined
Dec 28, 2015
Messages
6
Reaction score
0
First Language
English
Hey Shaz is it possible for me to put this in the options menu so the player can manually clear the cache?
 

doranikofu

Veteran
Veteran
Joined
Oct 4, 2015
Messages
113
Reaction score
31
First Language
Chinese
Primarily Uses
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~
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,618
Reaction score
13,212
First Language
English
Primarily Uses
RMMV
@YunoYukiAkise you could do that, but it would need some modificiation.


@doranikofu I don't think audio files are cached.
 

biud436

Veteran
Veteran
Joined
Sep 28, 2014
Messages
163
Reaction score
161
First Language
Korean
Primarily Uses
RMMV
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
 

TenTranVN

Veteran
Veteran
Joined
Apr 13, 2017
Messages
165
Reaction score
17
First Language
Vietnam
Primarily Uses
RMMV
Does it still work on 1.6.1?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,618
Reaction score
13,212
First Language
English
Primarily Uses
RMMV
did you try it and see?
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,415
Reaction score
669
First Language
Portuguese - Br
Primarily Uses
RMMV
Hi there!
In your code:
Code:
var params = PluginManager.parameters('CacheManager');
Does that mean that i have to rename the file to CacheManager.js ?
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,415
Reaction score
669
First Language
Portuguese - Br
Primarily Uses
RMMV
Sorry! Its a bite to late in Brazil :rswt
Thanks!
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,113
Reaction score
10,541
First Language
Czech
Primarily Uses
RMMV
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.
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,415
Reaction score
669
First Language
Portuguese - Br
Primarily Uses
RMMV
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.


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?
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,113
Reaction score
10,541
First Language
Czech
Primarily Uses
RMMV
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.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,618
Reaction score
13,212
First Language
English
Primarily Uses
RMMV
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.
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,415
Reaction score
669
First Language
Portuguese - Br
Primarily Uses
RMMV
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!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

When you realize @Kupotepo is a champion among RM Web users, and it all makes sense now:
Worst nightmare this morning, tried to get 20 minutes of work done on my project before heading to work and got hit with a POWER SURGE. Restarted my computer and the project was CORRUPTED, luckily I made a back up a few days ago so I only lost 4 days of work but still
Ami
what the other name of Elixir?

many games are use that,i want name it different.
What does your project folder look like?
I was told that an iPhone can provide a personal internet hotspot...You learn something new everyday!

Forum statistics

Threads
100,461
Messages
976,198
Members
132,082
Latest member
nwr
Top