Re: Review: Hot standby - Mailing list pgsql-hackers

From Simon Riggs
Subject Re: Review: Hot standby
Date
Msg-id 1227352120.7015.133.camel@hp_dx2400_1
Whole thread Raw
In response to Re: Review: Hot standby  ("Pavan Deolasee" <pavan.deolasee@gmail.com>)
List pgsql-hackers
On Sat, 2008-11-22 at 15:14 +0530, Pavan Deolasee wrote:

>         
>         The malloc was part of the existing code, explained by
>         comments.
>         
> 
> Oh I see. But I don't see any explanations for using malloc instead of
> palloc. Not that the current patch is responsible for this, I am
> wondering why its done that way and if we are freeing the malloced
> memory at all ?
> 
> malloc is used at another place in a new code. Although it seems that
> the allocation happens just once, please check if its better to use
> palloc there.

Thanks for your comments. OK, here's my thoughts after checking.

The malloc in the current code occurs within GetSnapshotData where it
exists to optimise memory allocation. The memory is allocated once and
never released, so malloc is appropriate.

The patch adds another use of malloc in GetRunningTransactionData()
which is similar to GetSnapshotData in many ways. It only ever runs
within bgwriter, and again, once allocated the memory is never released.
So malloc is appropriate there also.

I will change the #define as you suggested earlier.

-- Simon Riggs           www.2ndQuadrant.comPostgreSQL Training, Services and Support



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: HEAD build failure on win32 mingw
Next
From: Bruce Momjian
Date:
Subject: Re: Updates of SE-PostgreSQL 8.4devel patches (r1197)