Small patch for memory leak in src/backend/catalog/pg_proc.c

Started by Denis Perchineabout 26 years ago5 messagespatches
Jump to latest
#1Denis Perchine
dyp@perchine.com

Hello all,

Someone just forget to free tuple after heap_insert.

--
Sincerely Yours,
Denis Perchine

----------------------------------
E-Mail: dyp@perchine.com
HomePage: http://www.perchine.com/dyp/
FidoNet: 2:5000/120.5
----------------------------------

Attachments:

pg_proc.c.patchtext/plain; name=pg_proc.c.patchDownload+1-0
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Denis Perchine (#1)
Re: Small patch for memory leak in src/backend/catalog/pg_proc.c
Denis Perchine <dyp@perchine.com> writes:
***************
*** 327,331 ****
--- 327,332 ----
  		CatalogCloseIndices(Num_pg_proc_indices, idescs);
  	}
  	heap_close(rel, RowExclusiveLock);
+ 	heap_freetuple(tup);
  	return tup->t_data->t_oid;
  }

Uh, you didn't notice that the tuple you just freed is still in use
on the next line?

Memory leaks like this are not worth worrying about because the memory
will be reclaimed at end of transaction --- maybe even sooner after
I improve the memory-context handling.

regards, tom lane

#3Denis Perchine
dyp@perchine.com
In reply to: Tom Lane (#2)
Re: Small patch for memory leak in src/backend/catalog/pg_proc.c

heap_close(rel, RowExclusiveLock);
+ heap_freetuple(tup);
return tup->t_data->t_oid;
}

Uh, you didn't notice that the tuple you just freed is still in use
on the next line?

That's right :-((( Will try to be a little bit more accurate.

Memory leaks like this are not worth worrying about because the memory
will be reclaimed at end of transaction --- maybe even sooner after
I improve the memory-context handling.

But anyway it is better to free memory, because transaction can be quite large.
New patch attached.

BTW, could you please say what memory leaks can be safely ignored.

--
Sincerely Yours,
Denis Perchine

----------------------------------
E-Mail: dyp@perchine.com
HomePage: http://www.perchine.com/dyp/
FidoNet: 2:5000/120.5
----------------------------------

Attachments:

pg_proc.c.patchtext/x-c; name=pg_proc.c.patchDownload+5-4
#4Denis Perchine
dyp@perchine.com
In reply to: Denis Perchine (#3)
Re: Small patch for memory leak in src/backend/catalog/pg_proc.c

But anyway it is better to free memory, because transaction can be quite large.
New patch attached.

:-((( Again small mistake.

--
Sincerely Yours,
Denis Perchine

----------------------------------
E-Mail: dyp@perchine.com
HomePage: http://www.perchine.com/dyp/
FidoNet: 2:5000/120.5
----------------------------------

Attachments:

pg_proc.c.patchtext/x-c; name=pg_proc.c.patchDownload+5-4
#5Bruce Momjian
bruce@momjian.us
In reply to: Denis Perchine (#4)
Re: Small patch for memory leak in src/backend/catalog/pg_proc.c

Applied.

But anyway it is better to free memory, because transaction can be quite large.
New patch attached.

:-((( Again small mistake.

--
Sincerely Yours,
Denis Perchine

----------------------------------
E-Mail: dyp@perchine.com
HomePage: http://www.perchine.com/dyp/
FidoNet: 2:5000/120.5
----------------------------------

[ Attachment, skipping... ]
Index: pg_proc.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/catalog/pg_proc.c,v
retrieving revision 1.43
diff -c -b -w -r1.43 pg_proc.c
*** pg_proc.c	2000/05/28 17:55:54	1.43
--- pg_proc.c	2000/06/13 15:31:57
***************
*** 67,72 ****
--- 67,73 ----
  	Oid			toid;
  	NameData	procname;
  	TupleDesc	tupDesc;
+ 	Oid		retval;
  	/* ----------------
  	 *	sanity checks
***************
*** 327,331 ****
  		CatalogCloseIndices(Num_pg_proc_indices, idescs);
  	}
  	heap_close(rel, RowExclusiveLock);
! 	return tup->t_data->t_oid;
  }
--- 328,334 ----
  		CatalogCloseIndices(Num_pg_proc_indices, idescs);
  	}
  	heap_close(rel, RowExclusiveLock);
! 	retval = tup->t_data->t_oid;
! 	heap_freetuple(tup);
! 	return retval;
  }
-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026