Q: drawback and advantage of ref-counting memory-cleanup vs java GC algorithms
%A: Ref-counting can’t deal with islands of circular references. I don’t know any advantage of RC.
%A: ref-counting is proven in c++ shared pointers, string implementations and a lot of STL containers.
Q: ref-counting is faster than mark-and-sweep? (No pauses.)
A: counter updates must be thread-safe
%A: more predictable. No sudden loss of cpu resources
%A: memory allocation for the counter is a major cost to boost authors.
Q3: how do you implement a queue in a single-threaded world?
%A: linked-list vs circular array.
Q3b: What if your circular array is out of capacity?
%%A: cc array is best for bounded data structure. So this occurrence is probably a design error.
%%A: Follow ArrayList. copy to a new array with 200% capacity.
%%A: Alternatively allocate an “overflow” array. This will break random access iterator but our queue need no random access.
Xtap uses circular buffer to pre-allocate memory.
Q3c: advantage of cc-array?
A: memory allocation is rare (or never).
A: For linked-list, the payload is already a full object, so memory allocation needed for new Node – the “wrapper” over the payload object.