qpid-proton mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rafael Schloming <...@alum.mit.edu>
Subject Re: pn_incref/pn_decref and Ruby
Date Mon, 02 Mar 2015 18:36:39 GMT
On Mon, Mar 2, 2015 at 1:12 PM, Darryl L. Pierce <dpierce@redhat.com> wrote:

> Do I need to use reference counting from within the Proton library even
> though I'm writing in a language that doesn't use them?
> I asked because I see calls to pn_incref/pn_decref in the Python
> bindings.

You are implicitly using reference counting whenever you use the C API. Any
proton object constructed via the C API has an initial reference count of
1, and most "pn_<blah>_free" methods are just aliases for pn_decref.
Whether or not you need to explicitly use pn_incref/pn_decref at any point
other than these times depends on your overall scheme for managing memory.
If two ruby objects will ever share a reference to the same C object, then
explicitly using pn_incref/pn_decref is likely the most sensible way to
manage things. If however you are maintaining a one-to-one mapping between
ruby wrapper and C object, then you may not have to use pn_incref/decref


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message