Thread: What is '-Xmx1024m'? Why is it needed, ect.

Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 25
  1. #11  
    Registered Member

    Join Date
    Oct 2007
    Posts
    2,413
    Thanks given
    254
    Thanks received
    479
    Rep Power
    2785
    Quote Originally Posted by i r maggot View Post
    Example?

    Sorry
    I can't really give you an example of a memory leak, eh.

    Quote Originally Posted by Seecon View Post
    Does this involve the Garbage Collector not cleaning up or what?
    Umm, not really.
    Reply With Quote  
     

  2. #12  
    Registered Member bazinger's Avatar
    Join Date
    Nov 2008
    Age
    34
    Posts
    106
    Thanks given
    6
    Thanks received
    2
    Rep Power
    44
    Quote Originally Posted by i r maggot View Post
    Example?

    Sorry
    Here's an easy example...

    Some servers require a command to reload the drops table.
    Now if the drops table loads into system memory, it will add to the heap.

    When you reset the drops, it loads into the memory again - but the old load is still there as well. So when you use more heap than is allocated, you get a memory "leak".
    Quote Originally Posted by pro k0er View Post
    100mb connection is ****
    Lol'd
    Reply With Quote  
     

  3. #13  
    SERGEANT OF THE MASTER SERGEANTS MOST IMPORTANT PERSON OF EXTREME SERGEANTS TO THE MAX!

    cube's Avatar
    Join Date
    Jun 2007
    Posts
    8,871
    Thanks given
    1,854
    Thanks received
    4,745
    Rep Power
    5000
    There's a section for these nowadays. http://www.rune-server.org/forumdisplay.php?f=656

    Attached image

    Reply With Quote  
     

  4. #14  
    Registered Member

    Join Date
    Oct 2007
    Posts
    2,413
    Thanks given
    254
    Thanks received
    479
    Rep Power
    2785
    Quote Originally Posted by S Quare Quxx View Post
    There's a section for these nowadays. http://www.rune-server.org/forumdisplay.php?f=656
    Oh yeah, well as you see I haven't been very active on these forums lately, so I forgot. Sorry.
    Reply With Quote  
     

  5. #15  
    Programmer, Contributor, RM and Veteran




    Join Date
    Mar 2007
    Posts
    5,147
    Thanks given
    2,656
    Thanks received
    3,731
    Rep Power
    5000
    Quote Originally Posted by Seecon View Post
    Does this involve the Garbage Collector not cleaning up or what?
    No, it means the programmer has not released all references to the object.

    Say for instance I made a class like this:

    Code:
    public class VeryLargeObject {
        public byte[] lotsOfData = new byte[10241024];
    }
    And then another class that did something with them:

    Code:
    public TestClass {
        public VeryLargeObject[] objects = new VeryLargeObject[10];
    
        public TestClass() {
            for(int i = 0; i < objects.length; i++) objects[i] = new VeryLargeObject();
        }
    }
    And then wrote a piece of code like this:

    Code:
    public static void main(String[] args) throws InterruptedException {
        TestClass test = new TestClass();
        while(true) {
            // doing something with TestClass to ensure it doesn't get optimized away
            System.out.println(test.getClass());
            Thread.sleep(10000L);
        }
    }
    Because there are still references to the object, the garbage collector will not delete it and it will take up memory.

    The garbage collector will do its best to delete objects if you need more memory (i.e. when the heap space runs out, and you try to allocate more memory, it'll try to delete unused memory), or when System.gc() is called and I also think it does it on a schedule in most VMs.

    However, the problem Gnarly is talking about, is where you accidently leave references to an object. Like in the example above, the objects array could still be accessed, so the garbage collector does not delete it and it sits there taking a lot of memory.

    You can ensure this doesn't happening by setting references to an object to null where appropriate. However *this does not need to be done all the time* (and some code here does it too much).

    For instance, say you had this method:

    Code:
    public void doSomething() {
        Object o = new Object();
        // now do some stuff
    }
    You do not need to set o to null at the end, because the reference is lost when the method exists anyway.

    The same goes for a class like this:

    Code:
    public class MyClass {
         public Object someObject = new Object();
    }
    If you had some code that used it like this:

    Code:
    MyClass class = new MyClass();
    // now do something
    At the end many people here would write

    Code:
    class.someObject = null;
    class = null;
    However, in this case, it is not necessary and you just need to do

    Code:
    class = null;
    What you do need to be wary of is:

    - references of an object in others that are not going to be garbage collected
    - references of an object in collections in other classes/instances of that class - needs to be removed from the collection otherwise a reference remains and it will not be garbage collected.
    - probably more situations, you just get to know the best way of doing this with experience.
    .
    Reply With Quote  
     

  6. #16  
    What is '-Xmx1024m'? Why is it needed, ect.



    Scu11's Avatar
    Join Date
    Aug 2007
    Age
    30
    Posts
    16,307
    Thanks given
    7,215
    Thanks received
    12,308
    Rep Power
    5000
    What idiot mod moved it from tutorials to here? It goes in informative threads.

    Attached image
    Reply With Quote  
     

  7. #17  
    Registered Member

    Join Date
    Jun 2009
    Posts
    454
    Thanks given
    31
    Thanks received
    48
    Rep Power
    168
    What if........ You can use -Xmx1024m in your run.bat file?

    I seem to have done something with my environment variables and to be able to compile scripts with rsbot but now when I run my server and it say I can't use the xmx command thingy or it something about the Java VM couldn't start up or something like that......
    rswiki.info

    Help the rsps community by contributing knowledge!
    Reply With Quote  
     

  8. #18  
    Banned

    Join Date
    Jul 2009
    Posts
    3,999
    Thanks given
    1,003
    Thanks received
    1,028
    Rep Power
    0
    Sweet.
    Reply With Quote  
     

  9. #19  
    Registered Member

    Join Date
    Sep 2007
    Age
    32
    Posts
    2,396
    Thanks given
    5
    Thanks received
    436
    Rep Power
    902
    2048mb is way too much, 1024 should be more than enough, even with worldmaps loaded, and the whole cache decompressed and stored in memory. Other than that good thread.
    Hyperion V2 Martin's Updates.

    Scar says:
    i hate it when it hits your face
    Reply With Quote  
     

  10. #20  
    Banned

    Join Date
    Jul 2008
    Age
    28
    Posts
    5,827
    Thanks given
    1,301
    Thanks received
    197
    Rep Power
    0
    Explain how to use the commands, and move to the informative section.

    EDIT:
    Someone needs to explain what a memory leak is and why the GC doesn't clean up after objects that still have references.
    Reply With Quote  
     

Page 2 of 3 FirstFirst 123 LastLast

Thread Information
Users Browsing this Thread

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


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •