482 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
1
vote
3
answers
123
views
Should reference counters always be used when creating a Tcl object?
There's a whole page on the Tcl wiki, but there are a lot of examples and it's hard for me to find them.
Here are two simple cases that I often use:
Tcl_Obj *innerObj = NULL;
innerObj = Tcl_NewListObj(...
0
votes
1
answer
104
views
Why does dropping a `&mut Rc<_>` do nothing? How to explicitly drop an `Rc<_>`?
I have a Scene struct holding resources for the program and Objects referencing resources of the scene and also being owned by the scene. So the resources are wrapped in Rc<>.
Rust playground
...
0
votes
0
answers
21
views
In OpenCL, do contexts keep subdevices alive?
In OpenCL (let's say v3.0), I know one can create contexts using sub-devices. But - what happens if you release all references to a sub-device while the context is not released (i.e. has positive ...
0
votes
1
answer
63
views
Why ctypes.c_long.from_address.value yields reference count of an object?
In this pycon conference the presenter says that ctypes.c_long.from_address(id(SOME_OBJECT)).value would yields the reference count of an object.
I tried to find this in the documentation but found ...
0
votes
1
answer
141
views
Is this atomic reference counting optimisation safe in C?
Is this code safe knowing that:
Header_mark_as_shared is always only called before an object crosses to other threads, no matter in which thread it resides in
The first call to Header_mark_as_shared ...
3
votes
2
answers
253
views
Is this a correct implementation of atomic reference counting in C?
Giving the following constraints, is the optimization in this code correct?
before an object is transfered to another thread, its reference count is incremented and is_shared is set to true.
...
0
votes
0
answers
44
views
Conceptual understanding: Specifying lifetimes for singular object owning references to its own data [duplicate]
I am still a bit newer to rust and have been getting some practice through Advent of code problems.
I am curious if anyone would be able to explain to my why the borrow checker is dislikes the ...
2
votes
1
answer
91
views
Why reference count of None object is fixed?
I was experimenting with refcount of objects, and I noticed the reference count of None object does not change when I bind identifiers to None. I observed this behavior in python version 3.13.
Python ...
1
vote
1
answer
125
views
What is the canonical way to read a value inside an Arc?
There is probably no way this is the first time someone has asked this question, but for the life of me I couldn't find this answer. So I want to ask this in the hope that someone will either harshly ...
2
votes
1
answer
106
views
Can DecRef be optimized with refcount.load(std::memory_order_relaxed) == 1?
IncRef:
refcount.fetch_add(1, std::memory_order_relaxed)
DecRef:
if (refcount.load(std::memory_order_relaxed) == 1 ||
refcount.fetch_sub(1, std::memory_order_release) == 1) {
std::...
0
votes
0
answers
52
views
Objective C ARC: _foo in constructor autoincrements or not?
a bit related to In Objective-C MRR, if foo is a retain property, then self.foo = [[Foo alloc] init] will need to be released immediately?
suppose you have
@property (nonatomic, readwrite, retain) ...
0
votes
1
answer
97
views
Can the pages obtained by get_user_pages() be directly recycled or swapped out without using put_user_pages()?
get_user_pages() increments the page reference count. And that is why it can pin the page in memory.
So I wonder whether the pages obtained by get_user_pages() can be directly recycled or swapped out ...
0
votes
2
answers
127
views
How can I avoid Rc<String> extra pointer indirection?
I'm writing a bit of code that uses Rc<String>. I'm pretty sure that using this would create an extra pointer indirection, with one pointer to the Rc, which has a pointer to String, which is a ...
6
votes
0
answers
136
views
Under what circumstance can `sys.getrefcount()` return zero?
I was reading the Python 3.12 official documentation on the sys module, and the part about getrefcount() seems rather confusing to me (emphasis mine).
Return the reference count of the object. The ...
0
votes
0
answers
53
views
Direct access to the internal fields of a CPython object
To improve my understanding of Cython, I am trying to find a way to directly access the fields of the objects defined by CPython.
For example, I wrote the following code to access the ob_item field of ...