From: Chris <ctlajoie@gmail.com>
To: Craig Ringer <craig@postnewspapers.com.au>
To: pgsql-performance@postgresql.org
Subject: Re: How to troubleshoot high mem usage by postgres?
Date: Sat, 27 Feb 2010 18:17:57 -0700
Message-ID: <57033cf81002271717t6677b208v10679054673308d8@mail.gmail.com> (raw)
In-Reply-To: <4B899EFD.90200@postnewspapers.com.au>
References: <57033cf81002271429wb0da13am37b3cb6258103ea5@mail.gmail.com>
<4B899EFD.90200@postnewspapers.com.au>
On Sat, Feb 27, 2010 at 3:38 PM, Craig Ringer
<craig@postnewspapers.com.au> wrote:
> Can you boil this down to a simple PHP test-case that connects to a dummy
> database and repeats something that causes the backend to grow in memory
> usage? Trying to do this - by progressively cutting things out of your test
> until it stops growing - will help you track down what, exactly, is causing
> the growth.
Thank you for your suggestion. I have done this, and in doing so I
have also discovered why this problem is occurring.
My application uses a class that abstracts away the db interaction, so
I do not normally use the pg_* functions directly. Any time any
statement was executed, it created a new "named" prepared statement. I
wrongly assumed that calling pg_free_result() on the statement
resource would free this prepared statement inside of postgres.
I will simply modify the class to use an empty statement name if there
is no need for it to be named (which I actually need very infrequently
anyway).
I have attached the script I created to test with, for those who are
interested. The first line of the script has the connection string. I
used a db called testdb. run from the command line with:
php -f test3.php
Note my comment in the php file
<<<<<< UNCOMMENT THIS LINE AND MEMORY ISSUE IS FIXED
Thanks for the help everyone.
Chris
Attachments:
test3.php (application/octet-stream, 1.2K) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: ctlajoie@gmail.com, craig@postnewspapers.com.au
Subject: Re: How to troubleshoot high mem usage by postgres?
In-Reply-To: <57033cf81002271717t6677b208v10679054673308d8@mail.gmail.com>
References: <57033cf81002271429wb0da13am37b3cb6258103ea5@mail.gmail.com> <4B899EFD.90200@postnewspapers.com.au> <57033cf81002271717t6677b208v10679054673308d8@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox