Unload specific images from cache/ Cache Organisation

Discussion in 'JS Plugin Requests' started by Akrib, Apr 1, 2018.

  1. Akrib

    Akrib Villager Member

    Messages:
    20
    Likes Received:
    0
    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!
     
    #1
  2. Shaz

    Shaz Veteran Veteran

    Messages:
    37,307
    Likes Received:
    11,121
    Location:
    Australia
    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.
     
    #2
  3. Akrib

    Akrib Villager Member

    Messages:
    20
    Likes Received:
    0
    Hm, am I missing something here? If the cache is never ever cleared, then what exactly does the garbage collection do?
     
    #3
  4. Andar

    Andar Veteran Veteran

    Messages:
    28,131
    Likes Received:
    6,372
    Location:
    Germany
    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.
     
    #4
  5. Shaz

    Shaz Veteran Veteran

    Messages:
    37,307
    Likes Received:
    11,121
    Location:
    Australia
    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.
     
    #5
  6. peq42_

    peq42_ Yeet Veteran

    Messages:
    452
    Likes Received:
    267
    Location:
    Brazil
    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
     
    #6

Share This Page