Plugin Efficiency?

Discussion in 'Plugin Development' started by MrTwiggy, Jul 20, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    MrTwiggy

    Hey, there. I'm currently working on an arena plugin, that features the ability for multiple simultaneous matches, special abilities, etc. Additionally, the server I've been using has been having RAM issues (It has 1GB of ram, and crashes with RunOutOfMemory), and I'm not sure if it's server side or something to do with my plugin being to intensive.

    The most intensive thing I can think about on my plugin, there is a Sync scheduler that runs once every 1 second (repeating task), and it does 3 things. It updates all the matches, and by this I mean it goes through the list of all current matches (usually around 3), and essentially checks over variables, udpates require variables (checks for certain things like teamsize and players dead/alive, etc. It updates all the players, by going through each player's own object (custom class, NOT the Player obj), and checks to see if certain special ability timers need updating, etc. (Mainly just a few if statements per player, or decrementing an int variable) And lastly, updating signs by checking certain variables and doing 'setLine's and such.

    By looking at it, it sort of seems expensive and intensive, however in comparison to larger plugins, it doesn't seem like it would be that big of a deal. The plugin is around 70kb.

    Anywho, is that too inefficient / costly, moreso than other plugins out there?
     
  2. Offline

    tabr

    1gb - too low!
     
  3. Offline

    Sagacious_Zed Bukkit Docs

    The out of memory problem would depend on how many plugins you are running, and how many players you currently have connected. A small server would not need more than 1gb but larger one will.

    Also it is worth inspecting the heap size of your server to see if your plugin is leaking memory.
    Jar size while is an indication of complexity, is not a good indication of processing space or time needed.
     
  4. Offline

    MrTwiggy

    How can I inspect the heap size of my server? And how can I tell what a memory leak is, as well as how to solve it? Any idea of what common memory leaks are/how they are fixed?
     
  5. Offline

    Sagacious_Zed Bukkit Docs

    You will need a profile like VisualVM which ships with oracle's JDK. A memory leak is when you plugin hold onto uneed references. You can fix that be restructuring so that references are nulled out or removed. Commonly with collections that are never cleared.
     
  6. Offline

    r0306

    MrTwiggy
    I'm not too clear on this so someone correct me if I'm wrong. Memory leaks occur when the JVM cannot unload static variables and so keep them stored in the RAM. This data cannot be removed by the garbage collector and ends up just sitting there on your memory and taking up precious space. Memory leaks are not that obvious. You can't determine if it's a memory leak by just running the server for 10 minutes. It takes several days of reloading the server to notice that the computer is running low on memory, which forces you to restart. Most likely, they are caused by using too many static variables such as storing the Player object (which I have only recently got out of the habit of doing). Most importantly, go through your code and make sure that you cancel any unneeded tasks so that they aren't building up and simplify excessive code into more efficient ones.
     
  7. Offline

    p000ison

    Server shouldnt be the problem. I test my plugins on a 500mb server. Its 100% enough for 2 people xD

    But you can show us the source. Thats the only way we can help you. :p
    Sry for double post. Im online with my mobile :/

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
Thread Status:
Not open for further replies.

Share This Page