Solved What's the deal with storing players?

Discussion in 'Plugin Development' started by Alshain01, Oct 11, 2013.

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

    Alshain01

    I keep seeing people say not to store players but nobody ever seems to explain why not? Care to enlighten me?

    Also when they say "store" do they mean just don't store it in global hash maps and lists or don't ever declare a Player variable no matter how low scope and temporary?

    Much appreciation to anyone who can clarify this confusion.
     
  2. Offline

    1Rogue

    Mostly, memory leaks.

    When a player logs off their player object should be released to memory. Storing that in a plugin prevents that from happening.
     
  3. Offline

    Alshain01

    I see, so that really shouldn't be an issue for passing variables and temporary local variables then, right?
     
  4. Offline

    1Rogue


    No it would not.
     
  5. Offline

    The_Doctor_123

    Really, storing Players is a problem if you aren't removing them when Players quit.
     
  6. Offline

    Alshain01

    Gotcha, I'll keep that in mind. In most cases I try to keep storage as small of a construct as possible anyway as to not waste the server's memory. A String is smaller than a Player and retrieving the player has very little CPU impact.
     
  7. Offline

    The_Doctor_123

    Alshain01
    When you store a Player, you're just storing the reference, which is about as large in memory as a String.
     
Thread Status:
Not open for further replies.

Share This Page