Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.4) with ESMTP id fB4M93m23239 for ; Tue, 4 Dec 2001 17:09:03 -0500 (EST) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.4/8.11.4) id fB4Lepu90193 for pgsql-sql@postgresql.org; Tue, 4 Dec 2001 16:40:51 -0500 (EST) (envelope-from news) From: "Jeff Barrett" X-Newsgroups: comp.databases.postgresql.sql Subject: Memory exhausted in AllocSetAlloc(269039) Date: Tue, 4 Dec 2001 16:36:27 -0500 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 50 Message-ID: <9ujft0$2o2b$1@news.tht.net> X-Complaints-To: scrappy@hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 To: pgsql-sql@postgresql.org X-Archive-Number: 200112/40 X-Sequence-Number: 5863 I have a function that takes a comma seperated string from another table and parses it into another table. When I run it on a string with 130 ids it works fine, when I run it on a string with 50,000 ids (each about 6 characters long) I get the Error: Memory exhausted in AllocSetAlloc(269039). The system is a dual cpu intel with 1gig of ram and 1gig of swap space. Before I run the function I start top and it shows about 800mb of ram in use. This quickly excellerates until all ram is full and then fills up the swap space then postgres pukes the error message. It is running postgres 7.1. The questions I have are: Is my script that inefficent that I am using up all of my ram? (I know the string of ids in another table is horribly inefficent, but it is a historical nessesity I would rather avoid changing.) What is taking up all of this ram, how can I even trace the problem down? CREATE FUNCTION membidsintotable(INTEGER) RETURNS boolean AS ' DECLARE string_rec RECORD; resdataid ALIAS FOR $1; BEGIN SELECT INTO string_rec membids FROM listresultmembids WHERE listresdataid = resdataid; IF NOT FOUND THEN RETURN FALSE; END IF; WHILE char_length(string_rec.membids) > 0 LOOP INSERT INTO listmembids VALUES (resdataid, substring(string_rec.membids FROM 0 FOR position('','' in string_rec.membids))); string_rec.membids := trim(leading substring(string_rec.membids FROM 0 FOR position('','' in string_rec.membids)) FROM string_rec.membids); string_rec.membids := trim(leading '','' FROM string_rec.membids); END LOOP; RETURN TRUE; END; ' LANGUAGE 'plpgsql'; Thanks for the help, Jeff Barrett