Memory leak at net.minecraft.server.AxisAlignedBB ?

Discussion in 'Plugin Development' started by V10lator, May 19, 2012.

Thread Status:
Not open for further replies.
  1. Hi,
    some stability tests of MayaApocalypse showed that at some random point the server crashes cause there isn't any more RAM available. Of course we wanted to know what's the problem, so I profiled a test server with the help of the JProfiler. The result was horrible: net.minecraft.server.AxisAlignedBB (slowly) eats up the available RAM. Here's a little measurement:
    Code:
    Server start:
    15:10 - 485 kB
    Player join:
    15:10 - 525 kB
    Plugin starting:
    15:11 - 524 kB
    15:12 - 647 kB (2x mob rain - flood started)
    15:13 - 650 kB (desert (step 1) + meteor shower)
    15:14 - 663 kB (2x meteor shower)
    15:15 - 671 kB
    15:16 - 683 kB (meteor shower)
    15:17 - 694 kB
    15:18 - 733 kB (flood started + 2x meteor shower)
    15:19 - 715 kB
    15:20 - 717 kB (meteor shower)
    15:21 - 755 kB (meteor shower)
    15:22 - 740 kB (meteor shower)
    15:23 - 750 kB (mob rain)
    15:24 - 814 kB (mob rain + desert (step 2) + flood starting + meteor shower)
    15:25 - 783 kB (meteor shower)
    15:26 - 785 kB (2x spontaneous combustion + meteor shower)
    15:27 - 787 kB (spontaneous combustion + meteor shower)
    15:28 - 806 kB (meteor shower)
    15:29 - 820 kB
    15:30 - 835 kB (2x meteor shower + 2x spontaneous combustion + fire)
    A manual run of the GC doesn't change that values.
    Before you say "all the entities from your mob rains and meteor showers are causing this": No, they don't: The mobs from the rain are removed after the rain has finished and the explosions of the meteors don't drop items. Also the RAM used slowly grows even if the plugin is stopped (but then it's very slowly).
    The baddest thing is that the RAM eating is very randomly, so sometimes the plugin runs for hours before there's no more RAM, sometimes it just runs for a few minutes.
    And no: I'm not using net.minecraft.AxisAlignedBB directly.

    Can anyone confirm this? Any notes, comments, ideas?
     
  2. Offline

    Sorroko

    Well after quickly looking over the source of the file I can only guess its the fact that it doesnt remove the bounding boxes (As far as I can tell):
    Code:
    /** List of bounding boxes (not all necessarily being actively used) */
        private static List boundingBoxes = new ArrayList();
    So it just keeps them in memory?
    Apart from the fact of this:
    Code:
     /**
        * Sets the number of bounding boxes in use from the pool to 0 so they will be reused
        */
        public static void clearBoundingBoxPool()
        {
            numBoundingBoxesInUse = 0;
        }
    I wonder..
     
  3. ryan7745 Could you direct me to that code, cause I can't find it:
    $ cd ~/git/CraftBukkit-Bleeding
    $ grep -r boundingBoxes .
    $ cd ../mc-dev
    $ grep -r boundingBoxes .
    $
     
  4. Offline

    Sorroko

    V10lator likes this.
  5. Offline

    Acrobot

    V10lator likes this.
  6. Acrobot I'm to lazy to build a CB version with your patch (never got all the debs, ...) but could you send me (by PM) a compiled version with your fix? Would love to profile it. :)
     
  7. Offline

    Acrobot

Thread Status:
Not open for further replies.

Share This Page