Unload specific images from cache/ Cache Organisation

Akrib

Villager
Member
Joined
Jan 28, 2014
Messages
20
Reaction score
0
Primarily Uses
Hello everyone,

I searched a lot, but it seems like this has never really been adressed properly: Is there a script-call or a plugin to unload specific images from the image-cache?

This should be an important question for a lot of parallax mappers. I know that there is the automatic garbage collection which removes unused images after a time, but what about images used by parallax plugins that are not handled by the standard rpgmaker-methods? Are the images removed after each map change? Or are they even ever removed? Is this dependent on the plugin? Is there anybody who tested this with specific available plugins? Is it likely to encounter problems with memory leaks when using parallaxes for maps in rpgmmv?

Thanks in advance!
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
40,787
Reaction score
14,016
First Language
English
Primarily Uses
RMMV
I don't actually think there IS any emptying of the image cache during the game.

There is an ImageManager.clear() function, which clears the entire image cache, but it is not called from anywhere. And there is no function to remove individual images.

So once it's loaded, it stays loaded, and the cache just builds and builds until you exit completely.
 

Akrib

Villager
Member
Joined
Jan 28, 2014
Messages
20
Reaction score
0
Primarily Uses
Hm, am I missing something here? If the cache is never ever cleared, then what exactly does the garbage collection do?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,787
Reaction score
7,876
First Language
German
Primarily Uses
RMMV
The garbage collection does clear the image cache, but it works independently (which is why the clear function isn't used).

I think the only way to achieve what you want is to write a new plugin that replaces the original handling of the image cache and include its own preloaders for images. That preloader needs to give you the reference to the specific image loaded so that you can clear it manually, bypassing regular garbage collection.

The base problem here is that if you allow the Browser engine to load files on demand, it can not know when which file can be cleared - that is why the garbage collection needs to work without specific. You'll need something like a preloader (even if not for its original intention) to get a reference for memory that you then can decide yourself when to clear.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
40,787
Reaction score
14,016
First Language
English
Primarily Uses
RMMV
where does the garbage collection clear the image cache? I searched for the name of the object that holds all the images, and nothing cleared any of them.
 

peq42_

Yeet
Veteran
Joined
Feb 5, 2016
Messages
486
Reaction score
289
First Language
Portuguese(BR)
Primarily Uses
RMMV
I think that GC is a thing of the chromium, browser that runs the game, projected for the web.

From what I think I know, the best you can do is "mark" things as "not being used" (by using commands like the one showed above)and wait for GC to remove it automatically once it decides to, because that system was made for better browsing, so probably it loads everything that the tab needs, and only unload after a long time or after closing the tab
 

Latest Threads

Latest Posts

Latest Profile Posts

I finally got the ships and water to flow like I wanted to~ the canals are a success. Now to loop the animation for the kites. So many kites.
Bendyizzt wrote on staggqueen's profile.
Hello Newcomer...
I haven't make anything new yet, but I'm back addicted to writing some MZ plugins. Man, I wish I have more free time like I did 5 years ago.
Holy cow... work is demanding and I'm back in college. I'm kind of scared of my dad right now after the incident, but at least I don't live with him all the time. Anyway, working on Fandom Scouts and my FNAF character set. The FNAF sprites are actually going to be used in the game... unfortunately the enemy sprites are FNAF World traces, so no sharing those.

Forum statistics

Threads
107,691
Messages
1,031,477
Members
139,815
Latest member
noelyumishi
Top