On Sun, May 25, 2008 at 7:53 PM, Mary Anderson <[EMAIL PROTECTED]>
wrote:

> Hi,
>  Something in my program is eating up memory. I am running php 5 and
> hooking into postgres8.3, but I don't think it is a database program.
> The command in question works fine in psql,  the problem comes in loading a
> php variable.  And in the past, unsetting the variable has helped.
>
>
>
> BIG_SELECT is the only command which pulls a significant amount of data
> (40K to 2M) into the database.  In the real application, executing the
> function which runs this command results in an memory fault at the point in
> do_select_many that I have indicated.  However, this piece of test code runs
> just fine!  And the BIG_SELECT_cmd works just fine when cut and pasted
> directly into psql.  Sometimes, even the real application will work just
> fine.
> I am stymied.  I can neither isolate the problem in a piece of test code,
> nor can I reliably fix the problem when it occurs.  Any help on debuggers
> which will find memory leaks in php code, (Yeah. PHP 5.2 has some!) or
> tricks of the trade in finding them, or tips on where to look would be
> greatly appreciated.
> At this point, I really do not know when and where php frees memory. Let me
> be a little more specific:
>
>   1.  Does passing a large array as a reference into or out of a function
> save space?
>
Yes as you are not creating a duplicate of the array, but working on the
original


>
>        2.  Suppose I hit a submit button.  Are all the variables on the
> page still taking up space?

see point 7


>
>
>        3.  Any known bugs with pg_fetch_all running on 8.3?  How do I find
> them?
>
>        4.  Suppose I follow a link.  Do my variables on the old page still
> take up space?
>
see point 7

>
>        5.  Should I be handling my arrays one chunk at a time?
>
Do you really need all that data at once? Take a step back and look at what
you are attempting to do, perhaps some kind of roll-up or cube query could
do what you want, if you are aggregating the results, normally the reason
for a large result set.

Could you look at caching the results over a time when the server is lightly
loaded? It is truly important to have up to the minute results in the
resulting page?

>
>        6.  When I exit a php function, isn't all the space used by function
> variables freed?
>
No, its freed when the page in its entirety is done processing


>
>        7.  Why would it sometimes work to clear the cache?  This problem
> seems to me to be an intermittent one.
>
If you have multiple sessions asking for the same data, it will likely cause
a crash as well

>
>        8.  Most important,  what good programming practices should I be
> following to keep this from happening?
>
Think before you code. Its sounds rude and trivial, but in my experience,
all of the real issues in the code performance are related to developers not
understanding the true goal, or just not seeing the implications their
decisions on the design.


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


-- 

Bastien

Cat, the other other white meat

Reply via email to