Question regarding pfree and thread safety.

From: "Thomas Hallgren" <thhal(at)mailblocks(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Question regarding pfree and thread safety.
Date: 2004-01-16 07:44:31
Message-ID: bu84oo$f42$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Is it safe to call pfree() from multiple threads?

My Java backend will need to utilize finalizers. Objects like a saved
execution plan that has been "forgotten" must be released when the wrapping
Java object is finalized to avoid memory leaks. The finalizer is called from
the garbage collector which in turn might run in a separate thread. I have
two choices:

1. Let finalizers put pfree() candiates on a "death row" and let each call
from SQL into my call manager pfree() the candidates found there. All "death
row" management is of course subject to a mutex.

2. Let the finalizer call pfree directly and trust that it is thread safe.

Advice is greatly appreciated.

- thomas

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Huxton 2004-01-16 09:15:24 Re: Postgres v.7.3.4 - Performance tuning
Previous Message Joe Conway 2004-01-16 05:07:37 Re: [GENERAL] Bug and/or feature? Complex data types in