Subject: Re: [boost] another approach to memory management that solves thereferential cycles problem
From: Thomas Klimpel (Thomas.Klimpel_at_[hidden])
Date: 2009-02-25 12:59:11
Achilleas Margaritis wrote:
> The trouble with shared ptrs is that cyclic references can not be reclaimed.
> The problem can be solved using weak pointers, but this approach does not
> scale well in big projects that evolve over time with different developers.
The scaling behavior is certainly of utmost importance. How does the runtime and memory behavior of the proposed solution scales when the object graph becomes huge?
I think it would be great, if the proposed solution could be made to work. As you point out, there would be good reasons to use advanced memory management schemes that don't require weak pointers. However, "made to work" includes an acceptable amortized worst case bound for the runtime of the pointer/reference operations.
I have a bit the impression that releasing the reference to an object deep down in the object graph might take O(N) operations, at least for the provided "prototype" implementation. I might be wrong, or it might simply be a bug in the "prototype" implementation that can easily be fixed.
I also have the impression that the provided "prototype" implementation can sometimes detect a cycle and conclude from this cycle that an object is collectable, even if the cycle still has a path to a root reference. But again, I might be wrong, or it might simply be a bug in the "prototype" implementation that can easily be fixed.
> The idea is not considered a panacea for all memory management problems.
> It is only complementary to shared ptrs and manual memory management.
Can you be more explicit about the "known" problems of your approach?