Re[2]: When does PHP free-up memory allocated to it?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Richard,

Tuesday, May 22, 2007, 1:24:35 AM, you wrote:

>> I would have expected (or rather, hoped) that the memory use would
>> have dropped down quite dramatically after destroying the image
>> resource that was using up nearly 4MB of memory, but it didn't seem to
>> change.

> How are you measuring this?

memory_get_usage(true)

> What version of PHP?

5.2.2 (I did say :)

> The Memory Manager changed over the course of time.

Sure, but I'm only interested in how it works now :)

> I'm also not at all sure that you *can* measure it as precisely as you
> are trying to do.

I don't think you can measure it *accurately* right down to the byte,
but with big sweeping operations such as image resource deletion you
should see significant changes in value, and in some circumstances you
do (see blog link at the bottom)

> That said:
> PHP doesn't really allocate that 5.2M of RAM.
> GD does.

Horses for courses, surely? PHP asks GD to do it, the end result is
the same, the memory is being used.

> PHP may not be able to tell you accurately about what GD is doing
> internally -- but it's probably not *really* losing that 5.2M or you'd
> hear an awful lot more screaming about it from all quarters. :-)

True :)

Using the 5MB in the first place doesn't bother me, that's just a
simple allowance for each pixel of the image + RGB/Alpha values, which
is how GD works with it. What I found fascinating on further research
was how the memory can still be used depending simply on how you store
the image resource.

After more research I wrote about it here:
http://www.corephp.co.uk/archives/42-Interesting-memory-use-with-GD-images.html

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux