Search Postgresql Archives

Re: Memory Management in pqlib, Garbage Collection support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



(Sorry, I meant libpq). Actually it's finalize in Objective-C as well. PGSQLKit is the ObjC wrapper framework for libpq. I was confused by what I had learnt about GC, being it can't mix with non-GC. What the docu didn't mention in the places I read --or at least not so that it stuck-- was that it does link against C-libs regardless of GC and without throwing any kind of warning or error. 

So, if I understand this correctly, if I want to use GC in my frontend app, which links against PGSQLKit which links against libpq, I need to enhance PGSQLKit to support GC by adding finalizers for management of libpq's memory use to make GC available in all projects wanting to link against PGSQLKit, yes?



Am 03.05.2012 um 10:32 schrieb Simon Riggs:
Am 03.05.2012 um 10:13 schrieb Peter Bex:
> 
> OK, so you're specifically talking about Objective C.  I don't know much
> about that language, but unless there are specific ObjC-bindings for
> libpq (like libpq++ for C++), you'll need to perform manual memory
> management and call PQClear yourself.
> 
>> As GC is an evolutionary stage across languages [...]
> 
> […]

> I think if you want something similar you'll either need to write your
> own ObjC class to wrap the C functions or look for something pre-existing.
> Perhaps you can use libpq++.  I've also found a "PostgreSQL Cocoa Framework"
> project (but it appears to be abandoned): http://pgsqlcocoa.sourceforge.net/
Thanks for the pointer, but it's distributed under GPL, I can't use that. PGSQLKit is like PG, a BSD-style license. That's what brought me from MySQL to PG.

> 
>> In general there are libs that provide garbage collection for C as well, like here:
>> <http://www.hpl.hp.com/personal/Hans_Boehm/gc/>
> 
> The Boehm GC is a good prototyping solution but not very suitable for
> general use.  It's an especially bad idea to force use of such a garbage
> collector on the user whenever using libpq.  This would also prohibit
> the integration of libpq with other languages and their GCs.

I didn't look inside, I really just looked up Wikipedia on the subject and if there are ways to get GC into C somehow and seemed to have gotten lucky.

> AFAIK libpq currently does not offer specifying callback functions to
> use for allocating and freeing objects (it uses malloc/free directly).
> If this was available, it would be even easier to integrate deeply with
> a custom GC.
> 
>> For example, it'd help avoid leaks like those caused by a result not being PQclear'ed.
> 
> C programmers are generally comfortable with manual memory management, or
> they'd use another language.

It's ok, I like Cocoa's GC though.


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux