On sáb, 2007-01-27 at 20:05 +0000, Roman Neuhauser wrote:
> # [EMAIL PROTECTED] / 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.
>  
> > In any case, my second question is: Isn't too much memory 200 bytes for
> > a so simply object??
> 
> It's not memory consumption of that object.


AFAIK there's no other way to measure memory usage on PHP than this, if
you know something better it could be more constructive if you show it.

> 
> > And the third: Is there any manner to get more compact objects in PHP5?
> 
> You need to measure something before you want to compare it ("more
> compact" than what?)

If I say that I need a more compact car I think everyone understands me
without needing to say "than the one I own", so I think its pretty clear
what I'm asking for.
 
> > $before = memory_get_usage();
> 
> What's $before here?

Memory consumption until next code.

> 
> > $obj1 = new dummy (0);
> > $memdiff = memory_get_usage()-$before;
> > echo "Obj1 uses $memdiff bytes\n";
> > 
> > $before = memory_get_usage();
> 
> What's $before here?

The same as $before of before.

Thank you by your helpless comment.

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to