Skip site navigation (1) Skip section navigation (2)

Re: Memory management, palloc

From: Gavin Sherry <swm(at)linuxworld(dot)com(dot)au>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Memory management, palloc
Date: 2001-03-08 11:28:50
Message-ID: Pine.LNX.4.21.0103082204580.9685-100000@linuxworld.com.au (view raw)
Hi guys,

I've been looking through the memory management system today.

When a request is made for a memory memory chunk larger than
ALLOC_CHUNK_LIMIT, AllocSetAlloc() uses malloc() to give the request its
own block. The result is tested by AllocSetAlloc() to see if the memory
was allocated.

Irrespective of this, a chunk can be returned which has not had memory
allocated to it. There is no testing of the return status of
palloc() through out the code. 

Was/has this been addressed?

Thanks

Gavin


From: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
To: Gavin Sherry <swm(at)linuxworld(dot)com(dot)au>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Memory management, palloc
Date: 2001-03-08 14:54:29
Message-ID: 20010308155429.A11790@ara.zf.jcu.cz (view raw)
On Thu, Mar 08, 2001 at 10:28:50PM +1100, Gavin Sherry wrote:
> Hi guys,
> 
> I've been looking through the memory management system today.
> 
> When a request is made for a memory memory chunk larger than
> ALLOC_CHUNK_LIMIT, AllocSetAlloc() uses malloc() to give the request its
> own block. The result is tested by AllocSetAlloc() to see if the memory
> was allocated.
> 
> Irrespective of this, a chunk can be returned which has not had memory
> allocated to it. There is no testing of the return status of
> palloc() through out the code. 

 I don't understand. If some memory is not obtain in AllocSetAlloc()
all finish with elog(ERROR). Not exists way how return insufficient 
space. Or not?

		Karel

-- 
 Karel Zak  <zakkr(at)zf(dot)jcu(dot)cz>
 http://home.zf.jcu.cz/~zakkr/
 
 C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gavin Sherry <swm(at)linuxworld(dot)com(dot)au>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Memory management, palloc
Date: 2001-03-08 15:14:12
Message-ID: 25596.984064452@sss.pgh.pa.us (view raw)
Gavin Sherry <swm(at)linuxworld(dot)com(dot)au> writes:
> I've been looking through the memory management system today.

> When a request is made for a memory memory chunk larger than
> ALLOC_CHUNK_LIMIT, AllocSetAlloc() uses malloc() to give the request its
> own block. The result is tested by AllocSetAlloc() to see if the memory
> was allocated.

> Irrespective of this, a chunk can be returned which has not had memory
> allocated to it. There is no testing of the return status of
> palloc() through out the code. 

What's your point?

palloc() does not have the same specification as malloc.  It guarantees
to return allocated memory, or elog trying.

			regards, tom lane

From: Gavin Sherry <swm(at)linuxworld(dot)com(dot)au>
To: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Memory management, palloc
Date: 2001-03-08 15:19:14
Message-ID: Pine.LNX.4.21.0103090218390.11367-100000@linuxworld.com.au (view raw)
Karel,

On Thu, 8 Mar 2001, Karel Zak wrote:

> On Thu, Mar 08, 2001 at 10:28:50PM +1100, Gavin Sherry wrote:
> > Hi guys,
> > 
> > I've been looking through the memory management system today.
> > 
> > When a request is made for a memory memory chunk larger than
> > ALLOC_CHUNK_LIMIT, AllocSetAlloc() uses malloc() to give the request its
> > own block. The result is tested by AllocSetAlloc() to see if the memory
> > was allocated.
> > 
> > Irrespective of this, a chunk can be returned which has not had memory
> > allocated to it. There is no testing of the return status of
> > palloc() through out the code. 
> 
>  I don't understand. If some memory is not obtain in AllocSetAlloc()
> all finish with elog(ERROR). Not exists way how return insufficient 
> space. Or not?

Ahh. Of course. My mistake =)

Gavin



Privacy Policy | About PostgreSQL
Copyright © 1996-2013 The PostgreSQL Global Development Group