From: "Thomas Løcke" <tl@ada-dk.org>
Subject: Memory leak in GNATcoll or false positive from valgrind?
Date: Sat, 29 Jan 2011 12:33:52 +0100
Date: 2011-01-29T12:33:52+01:00 [thread overview]
Message-ID: <4d43fb20$0$23765$14726298@news.sunsite.dk> (raw)
Hey all,
I'm using this to connect to my PostgreSQL server:
function Database_Connection_Factory
(Desc : in GNATCOLL.SQL.Exec.Database_Description)
return GNATCOLL.SQL.Exec.Database_Connection
is
use GNATCOLL.SQL.Exec;
use GNATCOLL.SQL.Postgres;
DBMS : constant String := Get_DBMS (Desc);
begin
if DBMS = DBMS_Postgresql then
return Build_Postgres_Connection (Desc);
else
return null;
end if;
end Database_Connection_Factory;
declare
DB_Descr : GNATCOLL.SQL.Exec.Database_Description;
DB : SQL.Exec.Database_Connection;
C1 : SQL.Exec.Forward_Cursor;
begin
GNATCOLL.SQL.Exec.Setup_Database
(Description => DB_Descr,
Database => "my_database",
User => "my_user",
Host => "my_host",
Password => "my_password",
DBMS => GNATCOLL.SQL.Exec.DBMS_Postgresql,
SSL => GNATCOLL.SQL.Exec.Prefer);
DB := GNATCOLL.SQL.Exec.Get_Task_Connection
(Description => DB_Descr,
Factory => Database_Connection_Factory'Access);
C1.Fetch (Connection => DB,
Query => "select * from some_table");
while C1.Has_Row loop
Put_Line (C1.Value (Field => 1));
C1.Next;
end loop;
DB1.Commit_Or_Rollback;
end;
And it is working a charm, except that valgrind is reporting a leak when
I'm running it: http://pastebin.com/z66U5YAQ
I can make the leak go away, if I call Get_Task_Connection from a dummy
DB connection task that looks like this:
task body DB_Conn
is
use GNATCOLL.SQL.Exec;
begin
loop
select
accept Fetch (Conn : out Database_Connection;
Desc : in Database_Description) do
Conn := Get_Task_Connection
(Description => Desc,
Factory => Database_Connection_Factory'Access);
end Fetch;
or
terminate;
end select;
end loop;
end DB_Conn;
A mapping between the AWS tasks and the DB_Conn tasks are kept using the
Ada.Task_Attributes package:
package Task_Association is new Ada.Task_Attributes
(DB_Conn_Access, null);
This works, without a hitch. No leaks. Instead I get the annoying extra
DB_Conn layer. I'd much rather just go straight to Get_Task_Connection
from my AWS thread.
So, is this valgrind reporting a false positive, or am I doing something
wrong?
The above happens with GNATcoll (gnatlib) SVN revision 169867.
--
Thomas L�cke
Email: tl at ada-dk.org
Web: http//:ada-dk.org
http://identi.ca/thomaslocke
next reply other threads:[~2011-01-29 11:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-29 11:33 Thomas Løcke [this message]
2011-01-29 14:34 ` Memory leak in GNATcoll or false positive from valgrind? Thomas Løcke
2011-01-30 19:24 ` Emmanuel Briot
2011-01-31 7:06 ` Thomas Løcke
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox