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

Solved PocketMine memory free

Comments in 'Plugin Development' started by Inta, Jul 1, 2016.

  1. Inta
    Offline

    Inta Active Member

    Joined:
    Feb 11, 2016
    Posts:
    84
    Minecraft User:
    InstantlyTa
    How do PocketMine handle variable?
    For example if i assign $data in function for a freaking long string that take 3mb of RAM, will it automatically free up when i leave that function? Or i have to unset($data) or assign $data = null ?
  2. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Better unset it. And PocketMine handles NOTHING. PHP does the work.
    Inta likes this.
  3. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Of course it does unset variables that are on function scope
    PHP:
    <?php
    function bla(){
    $string "BLABLABLABLABLABLA";
    }
    bla();
    //No memory leak here
    Inta likes this.
  4. Extreme_Heat
    Offline

    Extreme_Heat Active Member

    Joined:
    Apr 19, 2016
    Posts:
    76
    Minecraft User:
    Extreme_Heat
    If the variable isn't being used anymore, the garbage collector will free the associated memory. Using unset() will not immediately remove the variable from memory, but will mark the memory associated with the variable to be freed when the garbage collector runs. Seting the variable to null will overwrite the data immediately, freeing the previous memory.
    Inta likes this.

Share This Page

Advertisement