CPU Buildup over time

Discussion in 'Plugin Development' started by tylersyme, Apr 14, 2014.

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

    tylersyme

    I've made a game for a server that gets about 50 players online avg. However I've been looking at the CPU and it steadily increases over time irregardless of player count. I've checked the timings multiple times and it's always, and I mean always 20TPS. RAM is just fine and rarely gets over a Gig even with 60+ players.

    It's a fairly large game with lots of MySQL, map switching, world importing etc.
    However I've brought down it's overall resource intensitivity down very low. None of the events or schedulers EVER even reach using 1% of a tick. Which is why I'm somewhat confused.

    We're running 1.7.5 with the only two big plugins besides the actual game being Essentials and NoCheat. All the others are just basic Async chat filter plugins plus buycraft and votifier

    We have to do world importing and such when the map in the game switches, but I've optimized that as much as possible. First I did it by unloading the previous world so that it didn't cause lag. However this apparently isn't done very well because it causes a memory leak. In answer to this I instead unloaded all of the chunks in these worlds rather than unloading the world itself. This fixed the RAM leak issue. I've checked to make sure that all the chunks are unloading and they are.

    I have an error in my coding. A hashmap with Player objects inside of it.. don't ask it's a long story :p. It may be a big deal I'm not entirely sure if can cause that bad of CPU usage but I do know I shouldn't be dong that. With this information, does this ring a bell to anyone? If so please speak up!
     
  2. Offline

    Gater12

    tylersyme
    HashMap storing Player objects can cause memory leaks if you do not know how to properly use them.
     
  3. Offline

    rfsantos1996

    Well, /timing helps A LOT, but keeping Players on a HashMap isn't bad, just remember to keep track of them and by this I mean avoiding memory leaks. This shouldn't be causing CPU issues.

    We can't help much without more info D;
     
  4. Offline

    tylersyme

    I quickly noticed that it created duplicates, so I made it only check if the names were the same. So I know I did that

    rfsantos1996
    I have one repeating non-async task that does some heavy math each second for each player. However that should be steady CPU, not CPU that goes up over time

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  5. Offline

    rfsantos1996

    Maybe there's a memory leak somewhere, making this task harder
     
Thread Status:
Not open for further replies.

Share This Page