Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id B593716AF4E5 for ; Mon, 30 Jul 2012 12:56:40 -0300 (ADT) Received: from moutng.kundenserver.de ([212.227.126.186]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SvsKj-0003Vv-Q9 for pgsql-bugs@postgresql.org; Mon, 30 Jul 2012 15:56:39 +0000 Received: from awork2.localnet (p5DDC7A9E.dip.t-dialin.net [93.220.122.158]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0M0N4b-1TnxxC0rOf-00uJZ0; Mon, 30 Jul 2012 17:56:23 +0200 From: Andres Freund Organization: 2ndquadrant.com To: Anderson Valadares Subject: Re: BUG #6785: Memory Leak in plpgsql Date: Mon, 30 Jul 2012 17:56:22 +0200 User-Agent: KMail/1.13.7 (Linux/3.5.0-rc6-andres-00196-gfdb1335; KDE/4.8.4; x86_64; ; ) Cc: pgsql-bugs@postgresql.org References: <201207301706.13963.andres@2ndquadrant.com> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201207301756.22678.andres@2ndquadrant.com> X-Provags-ID: V02:K0:PPeL0vfBRQuavzBiyGyqgihp4xJg1GCUhl5doDNTtuO 48XFeDQ/dC8scNQKUSmq+1wNsIsZV/QDfZ+rEGdpm2I2mw6H9o pravz0yzXctX65FhEb5gQfJu/+qMOgl/vwnTTvXY1YjwwanInu 4863aLii5zTRG0TXozI4+6Px/A9aZnzT5vehhb99w1gcL3dHcd rKHRmZC9oa89BhpWL4myNBhEqzI+ZtFMjhKje+MSmmV7y+a71O QGd5PWlw79mI5JZch7NSb8K0/Py9ruiYtr97BFMfxi895cGFTO IuoPufjbilhexZIavPMv1i/L0fQl+UjdlWH/ZOYjFSVCBVxa71 Hh0yhqrbO+6u9vGorVVRYu3XQul6ioHZ0UMiLtgwt X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201207/232 X-Sequence-Number: 33708 Hi, On Monday, July 30, 2012 05:38:07 PM Anderson Valadares wrote: > I understand, but the memory should not be returned after the execution of > the function? Well, that depends on how memory was allocated by the libc. When it used brk() to allocate memory its rather likely that the memory cannot directly be returned because some block of memory in the new memory is still used by some permanent memory context. > Below is the result of running with more than 55,000 calls. > > PID USER PR NI VIRT SWAP RES CODE DATA SHR S P %CPU %MEM TIME+ > COMMAND > 618 postgres 15 0 1687m 1.2g 507m 4684 505m 3796 S 1 0.0 4.2 0:04.90 > postgres: postgres test [local] idle Interesting. I just let the thing run - by accident - for 30+ minutes and it still hovered at 96MB. Greetings, Andres -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services