How to find a memory leak? Debugging?

Discussion in 'Plugin Development' started by Gabriel333, Oct 14, 2011.

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

    Gabriel333

    One of my users has found a memory leak, and has raised a ticket. I think memory leaks is serious , so I want to find the bug, but how?

    How do you guys debug your plugins? I have used trail and error for a long time now - but thats not very smart. (I use Eclipse for making the plugin)

    Any good advise?
     
  2. Offline

    XoX

    Look for where the memory is leaking out, and put a Bukkit underneath it so you can pour it back in once you patched up the leak.
     
  3. Offline

    Gabriel333

    :D
     
  4. Offline

    bergerkiller

    @Gabriel333 most common memory leaks are chunks not unloading. If you are cancelling chunk unloads, be aware that this unload call will no longer fire in the near future. (so you need to delay/schedule this chunk to unload manually later on)

    Other than that, look out for Player objects not getting cleared (from a HashMap). You can use a WeakHashMap if you expect the key to be cleared by the garbage collector, it does work.

    Also, make sure it is your plugin. It could be Spout has a memory leak and you are 'innocent'. :)
     
  5. Offline

    Gabriel333

    Thanks for the adwise... i cleaned up in my hashmap's and found a little bug there too :)

    I still miss a debugging tool ... :)
     
  6. Offline

    Afforess

    Never!

    Nah, it happens, but there are tools to identify them. Hashmaps/collections are the cause 99% of the time.
     
  7. Offline

    Gabriel333

    @Afforess : Im looking for at tool to find them, can you recommend any? (Im using eclipse for developing my plugin).
     
  8. Offline

    bergerkiller

    @Gabriel333 AFAIK there is no way to do this, but I could be wrong. Best is to look at collections and check if they can contain data that should be disposed. For example, you are storing chunks in a collection, if this chunk gets unloaded the memory slot is not released.
     
  9. Offline

    Gabriel333

    I checked my use of collections /HashMap's yesterday - because of your advise and I found one bug. Thanks!

    My problem is that my user still complains, so I guess I need to check my code one more :)
     
Thread Status:
Not open for further replies.

Share This Page