Like I said, I'm forking in order to not accumulate the memory leaks in the main program. Forking will increase the memory size of the new process only and get rid of it when it dies.
I have $tree = $tree->delete() and also undef ($tree). Also I put everything in a class and undefed the class, but I still see the memory increasing.