Private Memory Leak Leads to ORA-4030 (KOH-KGHU SESSI,PMUCALM COLL) Using UTL_FILE.FOPEN in PLSQL Loop

(Doc ID 734105.1)

Last updated on JULY 05, 2017

Applies to:

PL/SQL - Version 10.2.0.4 to 10.2.0.4 [Release 10.2]
Information in this document applies to any platform.
***Checked for relevance on 24th Nov 2016***

Symptoms

UTL.FILE.FOPEN leaks memory when called continously in a PLSQL loop. After a while it throws ORA-4030.

create or replace procedure utl_test (idx number) as
handle utl_file.file_type;
begin
 begin
   if (utl_file.is_open(handle) = FALSE) then
       handle := utl_file.fopen('DIR_TEST','utl_test_file.out','a');
   end if;
 exception
 when utl_file.invalid_operation then
   if (utl_file.is_open(handle) = FALSE) then
       handle := utl_file.fopen('DIR_TEST','utl_test_file.out','w');
   end if;
end;
utl_file.put_line(handle,'This is line: '||idx, TRUE);
utl_file.fclose(handle);
exception
 when others then
   dbms_output.put_line('In utl_test: '||SQLERRM);
end;
/

declare
  i number;
begin
  for i in 1..1000000000 loop
    utl_test(i);
  end loop;
end;
/



Open a session on the server and type "top" command. You will see the oracle process leaks memory.

After some time,  the following error is thrown:

ORA-4030: out of process memory when trying to allocate 16408 bytes (koh-kghusessi,pl/sql vc2)
ORA-29283: invalid file operation
ORA-6512: at "SYS.UTL_FILE", line 488
ORA-29283: invalid file operation
ORA-29283: invalid file operation
ORA-6512: at "SYS.UTL_FILE", line 29
ORA-6512: at "SYS.UTL_FILE", line 473
ORA-29283: invalid file operation


Also, you may observe the following logged in the alert.log:

ORA-600: internal error code, arguments: [12761], [], [], [], [], [], [], []
ORA-600: internal error code, arguments: [kghufree_06], [0x1104268D8], [0], [0], [0], [], [], []
ORA-4030: out of process memory when trying to allocate 16408 bytes (koh-kghu sessi, pmucpkl kolctx)

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms