Re: My objects eats too much (and weird!) memory

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

 



On Sat, January 27, 2007 2:12 pm, Francisco M. Marzoa Alonso wrote:
> On sáb, 2007-01-27 at 20:05 +0000, Roman Neuhauser wrote:
>> # francisco@xxxxxxxxxx / 2007-01-26 20:40:34 +0100:
>> > I've written this to check memory consumption of PHP5 objects,
>> because
>> > I'm having memory problems with an OO XMLParser that I've written.
>>
>> It measures something else though. The memory manager doesn't
>> allocate
>> memory for individual variables in PHP.
>>
>> > $ php MemTest.php
>> > Obj1 uses 208 bytes
>> > Obj2 uses 168 bytes
>> > Obj3 uses 200 bytes
>> > Obj4 uses 200 bytes
>> > Obj5 uses 200 bytes
>> > Obj6 uses 200 bytes
>> >
>> >
>> > I understand that first instance may be bigger than next ones
>> because
>> > method allocation and other things of that kind
>>
>> No.
>>
>> > but I do not understand why second instance is smaller than third
>> :-?
>>
>> It's not.

I believe PHP 5 allocates memory in "chunks" and then parcels it out
to your objects as needed.

I also *think* Roman was pointing out that you were not subtracting
the original memory_get_usage() from before/after in a consistent way
to actually find out how much each object was using.

All that said, 200 bytes for the object may or may not be excessive,
but you'd have to read PHP source to see what it's doing to see for
sure.

And absolutely for certain, there's no "compact mode" to run in where
objects take less RAM.

So if you're not happy with the RAM usage of objects, stop using
objects. :-)

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
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