refcounting

Why shared_ptr has an explicit constructor

I was wondering why shared_ptr doesn't have an implicit constructor. The fact it doesn't is alluded to here: http://stackoverflow.com/questions/142391/getting-a-boostsharedptr-for-this (I figured out the reason but thought it would be a fun question to post anyway.) #include <boost/shared_ptr.hpp> #include <iostream> using namespace b...

Why is my Python C Extension leaking memory?

The function below takes a python file handle, reads in packed binary data from the file, creates a Python dictionary and returns it. If I loop it endlessly, it'll continually consume RAM. What's wrong with my RefCounting? static PyObject* __binParse_getDBHeader(PyObject *self, PyObject *args){ PyObject *o; //generic object PyObject*...

Is there a way to get the current ref count of an object in Python?

Is there a way to get the current ref count of an object in Python? ...

AddRef and function signature

I've always used the following rule for signatures of functions that return ref-counted objects based on whether they do an AddRef or not, but want to explain it to my colleagues too... So my question is, is the rule described below a widely followed rule? I'm looking for pointers to (for example) coding rules that advocate this style. ...

Objective-C Memory Handling (iPhone)

I can't say I really understand the memory handling in Objective-C so I have a couple of questions concerning that. Do I have to remove the objects "url" and "urlRequest" in the box below or does "urlConnection" take on the responsibility for doing that? NSURL* url = [NSURL URLWithString:url]; NSURLRequest* urlRequest = [[NSURLRequest...

Are memory barriers necessary for atomic reference counting shared immutable data?

I have some immutable data structures that I would like to manage using reference counts, sharing them across threads on an SMP system. Here's what the release code looks like: void avocado_release(struct avocado *p) { if (atomic_dec(p->refcount) == 0) { free(p->pit); free(p->juicy_innards); free(p); } }...