Rupert Kittinger
Fri, 21 Apr 2006 11:09:20 -0700
Jeroen T. Vermeulen schrieb:
> On Fri, April 21, 2006 02:14, Dietmar Hummel wrote:
>
>> I have a really big problem with libpqxx 2.5.1 on a gentoo x86 system. My
>> little program consumes so much memory, that it get killed by the OS
>> after some minutes of running.
>
>> I use code like the following:
>
> Okay, this is a pretty clear example (in other words, thanks for a good
> bug report :)
>
> Two quick points for the record: (i) this is a relatively old version of
> libpqxx, so there's a small chance that the problem will just go away with
> an upgrade; and (ii) it may be useful at some point to know what compiler
> version and libpq version you are using.
>
>
>> template <typename TThis> void RoomBase<TThis>::ReadValue::operator()
>> ( argument_type &T )
>> {
>> ...
>> // Querystring wieder zusammenstellen
>> std::string strQuery = this is the SQL-statement UPDATE xxx ...
>>
>> // and the problem is the following line
>> T.exec( strQuery );
>>
>> ...
>> }
>
>> BTW: EVERY! T.exec()-call consumes very much memory.
>
> So the problem happens in this exec()... This is of course *not* supposed
> to leak memory. That is surprise #1.
>
> Surprise #2 is that you're getting big leaks from an UPDATE statement.
> That should not happen at all, because the result from an UPDATE doesn't
> contain much data! If I read the Valgrind output right, you're losing
>> 500 blocks of >2 KB each. Is this from a single call to this function?
>
>
>> Is there anything wrong? Do i miss a call to something like T.clear()?
>
> There is definitely something wrong. The exec() call is not supposed to
> use so much memory AFAICS (although it's all inside libpq so I don't
> really know what exactly goes on in there), and then the result value that
> is returned should get destroyed immediately, freeing up any memory it has
> allocated.
>
> Is there any way you can see whether the pqxx::result destructor is being
> called for every result object that has been created? In other words, is
> PQclear() being called right after the T.exec()?
>
> The call to PQclear() is in a function pqxx::internal::freemem_result() in
> src/util.cxx. You could set a breakpoint there in the debugger.
>
>
> Jeroen
>
>
There is a memory leak in 2.5.1 that was fixed in 2.5.2. See the mailing
list archives for details. I recommend upgrading to release 2.5.5 (which
works great for me :-)
Rupert
--
Rupert Kittinger <[EMAIL PROTECTED]>
Krenngasse 32
A-8010 Graz
Austria
_______________________________________________
Libpqxx-general mailing list
Libpqxx-general@gborg.postgresql.org
http://gborg.postgresql.org/mailman/listinfo/libpqxx-general