(Memory) How can I prevent Ram from increasing on custom plugin reload?

Discussion in 'Plugin Development' started by DanielTheDev, Apr 13, 2018.

Thread Status:
Not open for further replies.
  1. I'm currently working on my plugin, that includes reload function.
    But my concerns are that if I'm reloading my plugin with a custom command that includes onDisable() and onEnable(), the Ram will increase with 1 or 2 Mb.

    I'm unloading almost everything in the function onDisable() and onEnable() will initlize everything.

    Is there any way to clear every data from my plugin and reload it fully without increasing the Ram?
    And is there any way to check if how many instances inside my plugin are remaining in the Memory?
     
  2. Online

    timtower Administrator Administrator Moderator

  3. I don't prever doing that. I wan't to make the best version of a reload. but should I leave the variables and just run the important reload functions or just fully reload the plugin with the main methods?

    And is there any way to check if how many instances inside my plugin are remaining in the Memory?
     
  4. Online

    timtower Administrator Administrator Moderator

    What kind of reload are you using now?
    And do note that Bukkit isn't designed to be reloaded.
     
  5. I'm calling the onDisable() first and then the onEnable().
     
  6. Online

    timtower Administrator Administrator Moderator

    Bukkit has a lot of things in the background, don't think that you can catch everything.
     
  7. I have to ask it again. What is the best way to reload my plugin without perfoming the command /rl
     
    RcExtract likes this.
  8. Online

    timtower Administrator Administrator Moderator

    Depends on what you call a reload.
    There is a reloadConfig method.
     
  9. I mean fully reload my plugin so there is everything is fresh and clean.
     
  10. Online

    timtower Administrator Administrator Moderator

    As in reloading the classes after an export? Or just restart the plugin itself?
     
  11. No, I just wan't to re-initialize the entire plugin itself with the bukkit-api.
     
  12. Online

    timtower Administrator Administrator Moderator

    Then you need to unload and load it again.
    But then you get the same issues as you are having now as Bukkit isn't designed for this.
     
  13. Ok. and what would you recommend for this situation instead of typing /rl.
    Should I just create a simple 'only reload necessary functions' ?
     
  14. Online

    timtower Administrator Administrator Moderator

    @DanielTheDev I would not worry about that single mb.
    Make sure to stay away from static as it can't get cleaned by Bukkit.

    And if you worry: just restart the server.
     
  15. Thanks for you time and advise. I'm just a bit curious about 'stay away from the static'. Do you mean it will be cleaned or something else?
     
  16. Online

    timtower Administrator Administrator Moderator

    That it won't get cleaned at all.
     
Thread Status:
Not open for further replies.

Share This Page