Cache Manager

Discussion in 'JS Plugin Releases (RMMV)' started by Shaz, Nov 30, 2015.

  1. Shaz

    Shaz Veteran Veteran

    Messages:
    37,920
    Likes Received:
    11,586
    Location:
    Australia
    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: Nov 30, 2015
    #1
    Acetonide, SoSick., Archeia and 8 others like this.
  2. Liquidize

    Liquidize Caffeine Overload Developer

    Messages:
    466
    Likes Received:
    456
    Location:
    Somewhere.
    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?
     
    #2
    ArkDG likes this.
  3. Shaz

    Shaz Veteran Veteran

    Messages:
    37,920
    Likes Received:
    11,586
    Location:
    Australia
    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 ;)
     
    #3
    cybrim likes this.
  4. doranikofu

    doranikofu Veteran Veteran

    Messages:
    113
    Likes Received:
    31
    Location:
    United States
    First Language:
    Chinese
    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...
     
    #4
  5. Fox536

    Fox536 Veteran Veteran

    Messages:
    173
    Likes Received:
    60
    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.
     
    #5
  6. Shaz

    Shaz Veteran Veteran

    Messages:
    37,920
    Likes Received:
    11,586
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    It's not a perfect solution. Let us know how well it does work for you though :)
     
    #6
  7. YunoYukiAkise

    YunoYukiAkise Villager Member

    Messages:
    6
    Likes Received:
    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?
     
    #7
  8. doranikofu

    doranikofu Veteran Veteran

    Messages:
    113
    Likes Received:
    31
    Location:
    United States
    First Language:
    Chinese
    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~
     
    #8
  9. Shaz

    Shaz Veteran Veteran

    Messages:
    37,920
    Likes Received:
    11,586
    Location:
    Australia
    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.
     
    #9
  10. biud436

    biud436 Veteran Veteran

    Messages:
    152
    Likes Received:
    143
    Location:
    South Korea
    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
     
    #10
    TheTitan99 likes this.
  11. TenTranVN

    TenTranVN Veteran Veteran

    Messages:
    148
    Likes Received:
    16
    First Language:
    Vietnam
    Primarily Uses:
    RMMV
    Does it still work on 1.6.1?
     
    #11
  12. Shaz

    Shaz Veteran Veteran

    Messages:
    37,920
    Likes Received:
    11,586
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    did you try it and see?
     
    #12
  13. Eliaquim

    Eliaquim Raze: The Rakuen Zero's Guardian! Veteran

    Messages:
    854
    Likes Received:
    331
    Location:
    Brazil - Rio de Janeiro
    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 ?
     
    #13
  14. Shaz

    Shaz Veteran Veteran

    Messages:
    37,920
    Likes Received:
    11,586
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
     
    #14
    Eliaquim likes this.
  15. Eliaquim

    Eliaquim Raze: The Rakuen Zero's Guardian! Veteran

    Messages:
    854
    Likes Received:
    331
    Location:
    Brazil - Rio de Janeiro
    First Language:
    Portuguese - Br
    Primarily Uses:
    RMMV
    Sorry! Its a bite to late in Brazil :rswt
    Thanks!
     
    #15
  16. Poryg

    Poryg Dark Lord of the Castle of Javascreeps Veteran

    Messages:
    4,014
    Likes Received:
    10,159
    Location:
    Czech Republic
    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.
     
    #16
    Eliaquim likes this.
  17. Eliaquim

    Eliaquim Raze: The Rakuen Zero's Guardian! Veteran

    Messages:
    854
    Likes Received:
    331
    Location:
    Brazil - Rio de Janeiro
    First Language:
    Portuguese - Br
    Primarily Uses:
    RMMV
    @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.

    [​IMG]

    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?
     
    #17
  18. Poryg

    Poryg Dark Lord of the Castle of Javascreeps Veteran

    Messages:
    4,014
    Likes Received:
    10,159
    Location:
    Czech Republic
    First Language:
    Czech
    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.
     
    #18
    Eliaquim likes this.
  19. Shaz

    Shaz Veteran Veteran

    Messages:
    37,920
    Likes Received:
    11,586
    Location:
    Australia
    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.
     
    #19
    Eliaquim likes this.
  20. Eliaquim

    Eliaquim Raze: The Rakuen Zero's Guardian! Veteran

    Messages:
    854
    Likes Received:
    331
    Location:
    Brazil - Rio de Janeiro
    First Language:
    Portuguese - Br
    Primarily Uses:
    RMMV
    Understood! Thanks a lot!

    Oh, i see! Thanks for the answer!
     
    #20

Share This Page