X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 73CD55297D for ; Tue, 28 Jun 2005 15:47:38 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 17173-06 for ; Tue, 28 Jun 2005 18:47:28 +0000 (GMT) Received: from nproxy.gmail.com (nproxy.gmail.com [64.233.182.202]) by svr1.postgresql.org (Postfix) with ESMTP id 4208552849 for ; Tue, 28 Jun 2005 15:47:27 -0300 (ADT) Received: by nproxy.gmail.com with SMTP id x37so244731nfc for ; Tue, 28 Jun 2005 11:47:27 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=pE9wQHf2McJICzP+atG/1Cpw+U/1NCe1cE722KfVMYEig2QVkEAFdKOQSsRIJbdeblr+4fx6iWeQM0xMRQ2ap8rTzrgfg0qbh/iU5++JGQl144qlwJTFbFXZUAK8J8qpu/kdofkA/nu74E7E6436rYpHrsHzdZ18eVbQUHoYF3Q= Received: by 10.48.142.11 with SMTP id p11mr167598nfd; Tue, 28 Jun 2005 11:47:27 -0700 (PDT) Received: by 10.48.49.14 with HTTP; Tue, 28 Jun 2005 11:47:27 -0700 (PDT) Message-ID: <4b09a0c0506281147bc4b27f@mail.gmail.com> Date: Tue, 28 Jun 2005 20:47:27 +0200 From: Jean-Max Reymond Reply-To: Jean-Max Reymond To: pgsql-performance@postgresql.org Subject: Re: perl garbage collector In-Reply-To: <11126.1119938006@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <4b09a0c050627134660b3925@mail.gmail.com> <11126.1119938006@sss.pgh.pa.us> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.064 tagged_above=0 required=5 tests=AWL, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200506/571 X-Sequence-Number: 13208 2005/6/28, Tom Lane : > Jean-Max Reymond writes: > > I have a stored procedure written in perl and I doubt that perl's > > garbage collector is working :-( > > after a lot of work, postmaster has a size of 1100 Mb and I think > > that the keyword "undef" has no effects. >=20 > Check the PG list archives --- there's been previous discussion of > similar issues. I think we concluded that when Perl is built to use > its own private memory allocator, the results of that competing with > malloc are not very pretty :-(. You end up with a fragmented memory > map and no chance to give anything back to the OS. thanks Tom for your advice. I have read the discussion but a small test is very confusing for me. Consider this function: CREATE FUNCTION jmax() RETURNS integer AS $_$use strict; my $i=3D0; for ($i=3D0; $i<10000;$i++) { my $ch =3D "0123456789"x100000; my $res =3D spi_exec_query("select * from xdb_child where doc_id=3D100 and ele_id=3D3 "); } my $j=3D1;$_$ LANGUAGE plperlu SECURITY DEFINER; ALTER FUNCTION public.jmax() OWNER TO postgres; the line my $ch =3D "0123456789"x100000; is used to allocate 1Mb. the line my $res =3D spi_exec_query("select * from xdb_child where doc_id=3D100 and ele_id=3D3 limit 5"); simulates a query. without spi_exec_quer, the used memory in postmaster is a constant. So, I think that pl/perl manages correctly memory in this case. with spi_exec_query, postmaster grows and grows until the end of the loop.= =20 Si, it seems that spi_exec_query does not release all the memory after each call. For my application (in real life) afer millions of spi_exec_query, it grows up to 1Gb :-( --=20 Jean-Max Reymond CKR Solutions Open Source Nice France http://www.ckr-solutions.com