Cache and garbage collection

Discussion in 'RPG Maker MV' started by Akrib, Apr 1, 2018.

  1. Akrib

    Akrib Villager Member

    Messages:
    20
    Likes Received:
    0
    Hello everyone,

    I've searched almost everywhere but couldn't find any deeper explanations on the function of the cache and garbage collection of the rpgmaker (mv).
    I am currently working on a project which relies heavily on the use of parallaxes and overly images. Because of this it is very important for me to be able to unload images from the image cache to prevent the game from lagging after a certain time.

    Imagine the following: There is a large map (let's say around 100x100 tiles) which has to parallax layers for the whole map. These would be far too large just load with the start of the game, at least without causing the game to lag heavily. Instead, there would be a possibility to split these huge images into several small ones, that would be loading when the player enters the corresponding areas of the map.
    For example:
    Player is on coordinates x y, so image 1 is loaded, which displays the part of the map the player is currently in. Then the player moves to coordinates a b, so image 1 is erased and image 2 ist loaded, which shows the part of the map around these coordinates, without the player entering another map.

    While I am currently trying to event this system, my current problem is: When I am constantly loading and deleting parallaxes as the player walks through the map, will the deleted images get deleted out of the cache as well? Otherwise I'd have to fear lag or crashes.

    In short, is there someone who is able to explain:
    1. How the automatic garbage collection of rpgmmv works exactly?
    2. If there is a way to clear the cache from specific images via script calls?
    3. How the ImageManager.clear() function works? I tried this one on a map with tiles and parallaxes, and it didn't seem to do anything at all. Is the program reloading the cleared cache on the running map? Or did i do something wrong when making a script call "ImageManager.clear();"?

    Thanks a lot in advance! (and sorry for the long text...)
     
    #1
  2. peq42_

    peq42_ Yeet Veteran

    Messages:
    452
    Likes Received:
    267
    Location:
    Brazil
    First Language:
    Portuguese(BR)
    Primarily Uses:
    RMMV
    1) Garbage collection is not a thing of MV. It's from chromium(or what ever browser run your game. Be it mobile or not).
    2) I don't know if there is a way to use javascript to clear/remove images from the cache. But if there be, search on google how to do that in chrome, or general javascripts commands for that, because probably they will work(since anything that works on Chromium/Chrome, NodeJS or NWJS will work with MV games[At least, in desktop]).
    3)Think of the Garbage Collector as someone who holds all your things, follows/receive orders from you and have a list of the things he's carrying. If you use that "function", you're simply removing things from the list, but that guy won't simply drop them in the street. You're going to need to stop doing your activities(In your case, close the game/tab where it is running) for him to have free time to get rid of them(OR you need to wait some time, for him to start getting rid of a few things here and there as time passes, until all that was loaded and you asked him to get rid of be removed).
    At least I THINK that's the way it works.

    But you don't need to worry about it. Your game can reach up to 4GB of ram usage(If it be 64bits, AKA once MV 1.6 comes again and you update RM MV) without crashing(if it doesn't get to this point in a small amount of time) as far as I know. Also using lots of ram won't slow it down, it's quite the opposite: The more stuff you've loaded in RAM, the less the system will use CPU to load stuff(Because it will need a lot less time to load them from ram, than would to load from HDD/SSD), therefore the more performance you've.
     
    #2

Share This Page