From: Larry Garfield on
Hi folks. I have a complicated PHP app that is eating up more memory than I
think it should. I have a couple of theories as to where it could be going,
but I need some way to verify it.

There are a number of large data structures (mostly arrays) that get built up
throughout the course of the request. What I'd like to be able to do is at
certain points check to see how much memory those data structures are using.
Because they're not all built at once, the usual "check memory before, build,
check after" routine won't work. Plus, that gets screwed up by PHP's use of
copy-on-write at times.

I know that it would result in essentially over-reporting, but I would ideally
like to be able to ignore the copy-on-write issue and say "if this variable
were the only thing in memory (and its dependents, of course, for a nested
array), what would its memory usage be? I just have no idea how to do that.

Anyone have a suggestion for how to accomplish that?

--Larry Garfield
From: user on
ON Linux I have kcacheGrind setup with Xdebug and I find it is a nice
little thing to have. It won't tell you the memory consumed but it will
find cycles and display object maps. if you have Kcachegrind it is
likely you have valgrind installed.
http://www2.mandriva.com/
http://valgrind.org/
http://kcachegrind.sourceforge.net/html/Home.html
http://xdebug.org/
Larry Garfield wrote:
> Hi folks. I have a complicated PHP app that is eating up more memory than I
> think it should. I have a couple of theories as to where it could be going,
> but I need some way to verify it.
>
> There are a number of large data structures (mostly arrays) that get built up
> throughout the course of the request. What I'd like to be able to do is at
> certain points check to see how much memory those data structures are using.
> Because they're not all built at once, the usual "check memory before, build,
> check after" routine won't work. Plus, that gets screwed up by PHP's use of
> copy-on-write at times.
>
> I know that it would result in essentially over-reporting, but I would ideally
> like to be able to ignore the copy-on-write issue and say "if this variable
> were the only thing in memory (and its dependents, of course, for a nested
> array), what would its memory usage be? I just have no idea how to do that.
>
> Anyone have a suggestion for how to accomplish that?
>
> --Larry Garfield
From: "larry on
Yep, I'm familiar with XDebug and KCacheGrind. As you say, though, it
doens't (as far as I am aware) offer the particular data that I'm after.
We've already got cachegrind gurus working on the code who know how to
use it better than I do. :-) What I'm looking for is "see this big
cache object we've been building up in memory for this whole page
request? Now that we're done with the page, how big is it, really?"

--Larry Garfield

user(a)domain.invalid wrote:
> ON Linux I have kcacheGrind setup with Xdebug and I find it is a nice
> little thing to have. It won't tell you the memory consumed but it will
> find cycles and display object maps. if you have Kcachegrind it is
> likely you have valgrind installed.
> http://www2.mandriva.com/
> http://valgrind.org/
> http://kcachegrind.sourceforge.net/html/Home.html
> http://xdebug.org/
> Larry Garfield wrote:
>> Hi folks. I have a complicated PHP app that is eating up more memory
>> than I think it should. I have a couple of theories as to where it
>> could be going, but I need some way to verify it.
>>
>> There are a number of large data structures (mostly arrays) that get
>> built up throughout the course of the request. What I'd like to be
>> able to do is at certain points check to see how much memory those
>> data structures are using. Because they're not all built at once, the
>> usual "check memory before, build, check after" routine won't work.
>> Plus, that gets screwed up by PHP's use of copy-on-write at times.
>>
>> I know that it would result in essentially over-reporting, but I would
>> ideally like to be able to ignore the copy-on-write issue and say "if
>> this variable were the only thing in memory (and its dependents, of
>> course, for a nested array), what would its memory usage be? I just
>> have no idea how to do that.
>>
>> Anyone have a suggestion for how to accomplish that?
>>
>> --Larry Garfield
>
From: David Otton on
On 3 March 2010 15:49, larry(a)garfieldtech.com <larry(a)garfieldtech.com> wrote:

> Yep, I'm familiar with XDebug and KCacheGrind.  As you say, though, it
> doens't (as far as I am aware) offer the particular data that I'm after.
>  We've already got cachegrind gurus working on the code who know how to use
> it better than I do. :-)  What I'm looking for is "see this big cache object
> we've been building up in memory for this whole page request?  Now that
> we're done with the page, how big is it, really?"

You could try Memtrack (http://pecl.php.net/package/memtrack) but I
can't comment as to what state it's in.
From: dsiembab01 on
function check_memory_usage(&$memory)
{
$memory[] = memory_get_usage();
return $memory;
}

something like this?
you can put it wherever you like and returns an array for further
processing. You could optionally add a second argument to set the index
to a name and check if the name exists to add 1 to the end of the name
so your indexes stay maintained.
 |  Next  |  Last
Pages: 1 2
Prev: gentoo php
Next: basic authentication and redirection