1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

BuyCraft 1.2.2

BuyCraft ported for PocketMine-MP

  1. Fixed "Memory leak".

    Fixed a major memory leak. This issue manifested itself in memory allocation crashes and server instability. Thanks to @ijoshuahd for reporting!

    What was happening?
    (Almost) Everything in BuyCraft runs asynchronously so as to not block the main thread. When working with an AsyncTask it is important to remove all references to the Server object and the main thread. I have dealt with AsyncTasks before so I was sure to prevent this by only storing pieces of data like "is the plugin authenticated?" and "how many players are online?" in the task. I accomplished this by giving the task the plugin object and letting it pick what it wanted and then throw the object out after. Unfortunately, there was an arbitrary line of code which pulled the plugin object into the scope of the task class ($this->foo = $foo). The line was probably introduced by some late night or early morning coding season in which I didn't have my wits about me. Needless to say, none of my code depended on that line, and because of this it went by unnoticed. So why was this eating memory? When I gave the async task the plugin, I was giving it a pointer to where the plugin was stored in memory and not all the physical data. When that data was stored in the task by the bad line and the task was executed, PThreads realized that if both threads had a pointer to the same object bad stuff would happen with concurrent modification so it made a clone. The clone took up a huge chunk of memory and although it was released after execution, greatly impacted server performance.
    MineMobileCrafter and Dutok like this.
Return to update list...