What you see is a garbage collector doing its job.
When you override the value of a non-primitive variable, the old value is not immediately discarded from memory. It stays there as part of your memory usage script.
script , , script. , script - .
Edit:
. script , , , . , , , fwrite() , .