php memory de-allocation

Soldato
Joined
17 Jul 2008
Posts
2,820
Location
London
So after doing a spot of googling, I haven't found a good answer for this.

Got a script that runs daily on a client that operates on 500 records at a time. It fetches them and stores them in an object. What's the sensible way of clearing this object? What it does is this:

Code:
$obj = fetch500
while(more_records) {
   $obj = fetch500
   doStuff
}

Which is fine since the obj gets overwritten inside the while loop, but after the loop finishes, I want to clear the memory of this object. Should I use unset or set the object to NULL? Or something else that I am not aware of?

Yes I can increase memory limits... but I would prefer not to have a massive memory intensive script running daily xD.
 
Oh yeah its not that much but it is for the environment in question. And I would rather improve the script rather then blindly increase memory limits. Those records generate a 15-20mb object when loaded (there are other overheads as we have to do soap calls and such and such, but anyway that's not the issue here.

Was mostly asking for a sensible way to clear memory used by the variable (or mark it up for garbage collection) that is no longer needed while staying in the same function scope.
 
Back
Top Bottom