Hi Hackers,
I have been seeing memory usage increasing for a simple plpgsql function. Could you please take a look and check is it a bug?
The function definition is:
create function f() returns int as
$$DECLARE count int;
BEGIN
count := 1;
LOOP
count := count + 1;
begin
EXECUTE 'insert into test values(10)';
IF count > 1000000 THEN
EXIT;
END IF;
exception when others then
end;
END LOOP;
END$$
LANGUAGE plpgsql;
When I ran this function by "select f()", from top command, I could see memory usage (Resident memory) kept on increasing:
Then I used gdb to suspend the process each time insert was actually executed, and issued " (gdb) p MemoryContextStats(TopMemoryContext) ". From the server log, I saw only "SPI Proc" part of all the memory contexts was increasing:
My question: Is this problem as-designed?
Thank you for your time!!
Guangzhou