Memory leak in BootStrapXLOG()

Поиск
Список
Период
Сортировка
Искать
От
ITAGAKI Takahiro
Тема
Memory leak in BootStrapXLOG()
Дата
Msg-id
20050606152420.41C8.ITAGAKI.TAKAHIRO@lab.ntt.co.jp
Ответ на
Список
Дерево обсуждения
WAL: O_DIRECT and multipage-writer ITAGAKI Takahiro <itagaki.takahiro@lab.ntt.co.jp>
Re: [HACKERS] WAL: O_DIRECT and multipage-writer Mark Wong <markw@osdl.org>
Re: [HACKERS] WAL: O_DIRECT and multipage-writer ITAGAKI Takahiro <itagaki@tiara.ocn.ne.jp>
Re: [HACKERS] WAL: O_DIRECT and multipage-writer Mark Wong <markw@osdl.org>
Re: [HACKERS] WAL: O_DIRECT and multipage-writer (+ memory leak) ITAGAKI Takahiro <itagaki.takahiro@lab.ntt.co.jp>
Re: [HACKERS] WAL: O_DIRECT and multipage-writer (+ memory Bruce Momjian <pgman@candle.pha.pa.us>
Re: [HACKERS] WAL: O_DIRECT and multipage-writer (+ memory leak) Mark Wong <markw@osdl.org>
Re: [HACKERS] WAL: O_DIRECT and multipage-writer (+ Simon Riggs <simon@2ndquadrant.com>
Re: [HACKERS] WAL: O_DIRECT and multipage-writer (+ Bruce Momjian <pgman@candle.pha.pa.us>
Re: [HACKERS] WAL: O_DIRECT and multipage-writer (+ memory Bruce Momjian <pgman@candle.pha.pa.us>
Memory leak in BootStrapXLOG() ITAGAKI Takahiro <itagaki.takahiro@lab.ntt.co.jp>
Re: [HACKERS] WAL: O_DIRECT and multipage-writer (+ memory Tom Lane <tgl@sss.pgh.pa.us>
Re: [HACKERS] WAL: O_DIRECT and multipage-writer (+ memory Bruce Momjian <pgman@candle.pha.pa.us>
Re: [HACKERS] WAL: O_DIRECT and multipage-writer (+ memory Tom Lane <tgl@sss.pgh.pa.us>
Re: [HACKERS] WAL: O_DIRECT and multipage-writer Bruce Momjian <pgman@candle.pha.pa.us>
Re: [HACKERS] WAL: O_DIRECT and multipage-writer Mark Wong <markw@osdl.org>
Bruce Momjian  wrote:

> > BTW, I found memory leak in BootStrapXLOG(). The buffer allocated by malloc()
> > is not free()ed. ISSUE_BOOTSTRAP_MEMORYLEAK in this patch points out it.
> > (But this leak is not serious, because this function is called only once.)
> 
> Does the following patch fix the memory leak you described?

Yes, the revised patch has no leak by using stack instead of malloc().
This leak is trivial, but anyway direct io needs an aligned buffer. 
IMHO any of the following is ok.

[A] 1st patch
char *buffer;
void* buffer0;
buffer0 = malloc(BLCKSZ + XLOG_EXTRA_BUFFERS);
buffer = (char *) XLOG_BUFFERS_ALIGN(buffer0);
free(buffer0);

[B] 2nd patch
char *buffer;
char  buffer0[BLCKSZ + XLOG_EXTRA_BUFFERS + MAXIMUM_ALIGNOF];
buffer = XLOG_BUFFERS_ALIGN(buffer0);

[C] following code is simple if we don't care the memory leak.
char *buffer;
buffer = XLOG_BUFFERS_ALIGN( malloc(BLCKSZ + XLOG_EXTRA_BUFFERS) );


---
ITAGAKI Takahiro
NTT Cyber Space Laboratories


В списке pgsql-patches по дате отправления
От: Dennis Bjorklund
Дата:
Сообщение: Re: lastval()
От: Pavel Stehule
Дата:
Сообщение: Re: SQLSTATE again
FAQ