Memory management

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
crazycoders
Forum Contributor
Posts: 260
Joined: Tue Oct 28, 2008 7:48 am
Location: Montreal, Qc, Canada

Memory management

Post 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!
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Memory management

Post 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.
(#10850)
crazycoders
Forum Contributor
Posts: 260
Joined: Tue Oct 28, 2008 7:48 am
Location: Montreal, Qc, Canada

Re: Memory management

Post 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.
Post Reply