Search Postgresql Archives

Re: Memory Management in pqlib, Garbage Collection support

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

 



Thanks, that's answering my question. In Objective-C as well as many other languages there is the feature to turn on Garbage Collection. It's a separate thread that scans memory for strong pointers, their source and origin and "vacuums" memory so to not have any leaks. Anything unreferenced and no longer needed is cleaned up automatically. There are some border cases where GC can fail, but for most it works.

There are three values for the compiler: off, supported and required. One cannot mix subprojects unlike in e.g. ARC (Automated Reference Counting). Either it's on or off. Supported means that it covers both sides, "manual" memory management and automated management.

As GC is an evolutionary stage across languages, objects formerly deallocated or freed or released (or whatever other term is used across different languages) through a unique call or method name where one would normally also host any steps to release associated resources not necessarily memory related (closing sockets, file handles etc.), such call is replaced with the language specific call that the garbage collector calls to still provide for closing these resources while still being able to handle memory management in an automated fashion. All directly memory related calls become no-ops to provide for backward compatibility. In the end one can compile with GC on, or GC off and the compiler refers to the calls it needs to deal with the two aspects accordingly, either resource-only management or resource-and-memory management.

In general there are libs that provide garbage collection for C as well, like here:

For example, it'd help avoid leaks like those caused by a result not being PQclear'ed.

Alex


Am 03.05.2012 um 09:16 schrieb Peter Bex:

On Thu, May 03, 2012 at 09:08:53AM +0200, Alexander Reichstadt wrote:

Hi,

since I got no answer so far I searched through the docu again. I searched for GC as well as Garbage, and all garbage refers to is with regard to vacuuming a database. But my question refers to wether or not memory management is with garbage collection supported or not. When I try to link against pqlib, it seems I need to have garbage collection enabled in order for it to link. But the documentation mentions it nowhere.

What kind of garbage collection do you need to have enabled in order to link?

C is based on manual memory-management, and you can't generally have
garbage-collection in it.  Hence, libpq is *not* garbage-collected and
your statement that it needs "garbage collection enabled" doesn't make
much sense to me.

Are you talking about libpq bindings to some other language, perhaps?

Please, can someone confirm this or is this the wrong list?

This is the right list.

Cheers,
Peter
--
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
is especially attractive, not only because it can be economically
and scientifically rewarding, but also because it can be an aesthetic
experience much like composing poetry or music."
-- Donald Knuth

--
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