Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,811
Reaction score
14,977
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
567
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

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,811
Reaction score
14,977
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
32
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
61
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

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,811
Reaction score
14,977
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
32
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

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,811
Reaction score
14,977
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
173
Reaction score
185
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
175
Reaction score
19
First Language
Vietnam
Primarily Uses
RMMV
Does it still work on 1.6.1?
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,811
Reaction score
14,977
First Language
English
Primarily Uses
RMMV
did you try it and see?
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
2,030
Reaction score
1,504
First Language
Portuguese - Br
Primarily Uses
RMMZ
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
2,030
Reaction score
1,504
First Language
Portuguese - Br
Primarily Uses
RMMZ
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,135
Reaction score
10,670
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
2,030
Reaction score
1,504
First Language
Portuguese - Br
Primarily Uses
RMMZ
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.

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?
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,135
Reaction score
10,670
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

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,811
Reaction score
14,977
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
2,030
Reaction score
1,504
First Language
Portuguese - Br
Primarily Uses
RMMZ
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!
 

Latest Threads

Latest Profile Posts

SA57Face.pngSA57_IDLE.gifThis is just a "Chinese opera actor" who is totally not a serial killer. Now, we just need to clean up a pile of dead bodies found in his backyard. :kaojoy:
E7DsT3VXsAInVpu

working on my avatar, because i couldn't stand looking at it anymore :D
still not finished though...
alpacaraptors = love!
''Finds icons that fits the game you're making'' Only covers 20% of what you need :p
I'm very manic-y right now. I didn't sleep and I wanted to get a bunch of stuff done, but didn't get anything done except the bare bones concept for a POSSIBLE game.
And I can't sleep now because I'm probably gonna be hanging out with my brother and I gotta discuss a bunch of BroCoG (our game group) junk with him plus it's far to late to sleep NOW.
poppetQuestBarryApproaches.jpg
While I wait for judging, I decided to start adding more "friends" to my attic. :LZSgrin:

I swear I need a whole sound pack of menacing squeaky toy noises. :kaoswt:

Forum statistics

Threads
113,585
Messages
1,076,008
Members
147,568
Latest member
dnelson83
Top