Thread: How to make stupid PI code be less stupid

Results 1 to 10 of 10
  1. #1 How to make stupid PI code be less stupid 
    Super Donator

    Jack Daniels's Avatar
    Join Date
    Oct 2010
    Posts
    1,842
    Thanks given
    787
    Thanks received
    507
    Rep Power
    412
    Open Player class
    Note:
    What does static do?
    It makes a variable shared between objects
    since so it doesnt create an extra 50000k varialbles per Player object but only holds one
    Knowing that PI's having 150 players online average have about 4k player objects(cause of mem leaks, no shit, i tested myself using JVM and heapspace dump) after 10h online time , i think it is a good idea to consider changing some things to static lul

    add static
    in

    Code:
    public final int[][] MAGIC_SPELLS = {
    so that it becomes

    Code:
    public static final int[][] MAGIC_SPELLS = {
    do the same with:

    final int[] OTHER_RANGE_WEAPONS
    final int[] NO_ARROW_DROP
    int[] autocastIds
    int[] PRAYER_DRAIN_RATE
    String[] PRAYER_NAME
    etc

    can do this also with the variables
    public int playerHat = 0;
    public int playerCape = 1;
    public int playerAmulet = 2;
    public int playerWeapon = 3;
    public int playerChest = 4;
    public int playerShield = 5;
    public int playerLegs = 7;
    public int playerHands = 9;
    public int playerFeet = 10;
    public int playerRing = 12;
    public int playerArrows = 13;

    etc

    that wont get rid of your mem leak but that will slow it down about 5 times lul
    since the MAGIC SPELLS is like a int[100][2000] and having String arrays per player object is also a VERI bad idea


    New Skype : samar.server
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Mar 2011
    Posts
    76
    Thanks given
    3
    Thanks received
    1
    Rep Power
    1
    Hmm, thanks haha

    P.S - Nice title
    Reply With Quote  
     

  3. #3  
    Super Donator

    Benji's Avatar
    Join Date
    Feb 2010
    Age
    29
    Posts
    1,525
    Thanks given
    920
    Thanks received
    503
    Rep Power
    570
    MAGIC SPELLS is like a int[100][2000]
    its 40 x 16, not 100 x 2000

    Those variables shouldn't be in the Player class at all

    Reply With Quote  
     

  4. Thankful user:


  5. #4  
    Donator


    Join Date
    Mar 2008
    Posts
    1,945
    Thanks given
    118
    Thanks received
    201
    Rep Power
    2104
    You have no Idea what your talking about. The Issue everyone is experiencing with this so called memory leak is with npcs that are removed properly, Syncing issues causing a thread deadlock causing the server to use large amounts of memory instantly then crash with no errors. Its quite simple to find the issue with proper debugging.
    Reply With Quote  
     

  6. Thankful user:


  7. #5  
    Community Veteran


    Join Date
    Jun 2007
    Posts
    1,683
    Thanks given
    302
    Thanks received
    309
    Rep Power
    481
    Static final variables should all be declared in Config class.

    Quote Originally Posted by Lmctruck30 View Post
    You have no Idea what your talking about. The Issue everyone is experiencing with this so called memory leak is with npcs that are removed properly, Syncing issues causing a thread deadlock causing the server to use large amounts of memory instantly then crash with no errors. Its quite simple to find the issue with proper debugging.
    Are not removed properly you mean? What else do you have to do besides nulling them and changing x and y to 0?
    Reply With Quote  
     

  8. #6  
    Donator


    Join Date
    Mar 2008
    Posts
    1,945
    Thanks given
    118
    Thanks received
    201
    Rep Power
    2104
    Quote Originally Posted by Russian View Post
    Static final variables should all be declared in Config class.



    Are not removed properly you mean? What else do you have to do besides nulling them and changing x and y to 0?
    sometimes the npc will restore life but restore life in another position.
    Reply With Quote  
     

  9. #7  
    Registered Member
    Ninja assassin's Avatar
    Join Date
    Oct 2008
    Posts
    1,961
    Thanks given
    217
    Thanks received
    115
    Rep Power
    77
    was sanity that stupid when he made this or he deliberately left it for us to fix this..?
    maybe meh just stupid
    Btc: 1tpWTbAznzWYh6YpoUJeQ3MDVK56GGJ
    Reply With Quote  
     

  10. #8  
    Super Donator

    Jack Daniels's Avatar
    Join Date
    Oct 2010
    Posts
    1,842
    Thanks given
    787
    Thanks received
    507
    Rep Power
    412
    Quote Originally Posted by Benjii View Post
    its 40 x 16, not 100 x 2000

    Those variables shouldn't be in the Player class at all
    hurrdurr?


    New Skype : samar.server
    Reply With Quote  
     

  11. #9  
    Super Donator

    Jack Daniels's Avatar
    Join Date
    Oct 2010
    Posts
    1,842
    Thanks given
    787
    Thanks received
    507
    Rep Power
    412
    Quote Originally Posted by Lmctruck30 View Post
    You have no Idea what your talking about. The Issue everyone is experiencing with this so called memory leak is with npcs that are removed properly, Syncing issues causing a thread deadlock causing the server to use large amounts of memory instantly then crash with no errors. Its quite simple to find the issue with proper debugging.
    I actually do , get a PI , get 200 players online on it, open JVM , dump the heapspace, sort by largest objects, u'll see there are 5k client objects while only 150 ppl online , mem leak obv?


    New Skype : samar.server
    Reply With Quote  
     

  12. #10  
    RuneFatality

    Join Date
    May 2009
    Age
    27
    Posts
    2,350
    Thanks given
    1,099
    Thanks received
    388
    Rep Power
    531
    Stupidity to the next level.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 11
    Last Post: 08-30-2009, 01:26 AM
  2. Stupid Tuts For Stupid People
    By Huey in forum Tutorials
    Replies: 6
    Last Post: 01-01-2009, 10:48 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •