Page 1 of 1

Memory management

Posted: Wed May 13, 2009 8:27 am
by crazycoders
If you try to unset a value from an array, is it normal that the memory usage doesn't drop?
My guess is because php keeps the memory allocated in case it gets used later but i aint sure.

Can anyone confirm this? I want to make sure i don't have memory leaks in my code!

Re: Memory management

Posted: Wed May 13, 2009 11:29 am
by Christopher
Yes the memory will stay allocated. You really cannot manage memory or have "memory leaks" in PHP like you can in C, for example. All memory is freed at the end of each request, so the main focus is total usage. And remember that tricks that work in one PHP version may not work in another, and even make things worse.

Re: Memory management

Posted: Wed May 13, 2009 11:32 am
by crazycoders
Thanks,

I won't use any tricks in particular. I'm just making an object oriented data structure called a dataset (currently working on datatable, datarow and datacolumn) and i wanted to make sure why my unset of the data kept memory allocated and had a hunch that it stayed allocated, thanks for validating.