Questions tagged [reference-counting]
The reference-counting tag has no summary.
10 questions
0votes
1answer
232views
Should I let objects, whose copying is "costly", be naively copyable?
I'm devising an API - or actually, a wrapper API for another, lower-level API - in a programming language with objects. This API represents some entity E which is reference-counted (for example - a ...
0votes
2answers
862views
What problem does Rust's "atomic reference count" actually solve?
The Rust programming language offers a Arc atomic reference counting generic type for use in multi-threading environment, since Rc is optimized for performance in single-threaded applications, and ...
3votes
3answers
651views
What is the best way to retain a local object which is performing an asynchronous task?
My problem is the following: inside a method I'm creating an object like this: MyObject* myObject = [MyObject new]; Then I want it to perform an asynchronous task like this: [myObject ...
1vote
2answers
834views
How is it that reference counting is faster on Apple silicon Intel translation than on Intel?
I can't find the exact tweet, but it was stated by Apple engineers that the retain and release operations are faster on Intel x86 translation than on standard Intel x86.
0votes
2answers
227views
What's the canonical way to do compaction on a refcounted heap?
The only way I know of is to copy the whole heap by allocating copies of all objects on a new heap and dropping the old one, like couchbase db does for example. Presumably you could also do the same ...
11votes
5answers
5kviews
A reference counting pattern for memory managed languages?
Java and .NET have wonderful garbage collectors that manage memory for you, and convenient patterns for quickly releasing external objects (Closeable, IDisposable), but only if they are owned by a ...
6votes
4answers
820views
Strategy for avoiding defensive copies while keeping correct encapsulation
I want to keep a dependency decoupled, but at the same time, once it's passed to the constructor, I want to allow changes only through Whatever (in the following example) because changing the ...
-1votes
3answers
389views
I just used a goto statement. Is this OK? [closed]
I just wrote this code that uses a goto statement. if (PyMethod_Check(attrib_value)) { PyObject *im_self = PyObject_GetAttrString(attrib_value, "im_self"); if (im_self == Py_None) { ...
3votes
2answers
134views
COM - with great power comes great responsibility, but at what cost? (looking for advice on coding practices when working with COM)
What is best (or commonly accepted) practice for where to declare COM object variables (scope) and how to handle cleaning them up when using structured error handling? I just spend a whole load of ...
78votes
3answers
59kviews
How does garbage collection compare to reference counting? [duplicate]
I starting working through an online course on iOS development in the new language from Apple, Swift. The instructor made a point that raised this question in my mind. He said something to the ...