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!
Memory management
Moderator: General Moderators
-
crazycoders
- Forum Contributor
- Posts: 260
- Joined: Tue Oct 28, 2008 7:48 am
- Location: Montreal, Qc, Canada
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Memory management
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.
(#10850)
-
crazycoders
- Forum Contributor
- Posts: 260
- Joined: Tue Oct 28, 2008 7:48 am
- Location: Montreal, Qc, Canada
Re: Memory management
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.
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.