Hi folks,
da Silva, Joe wrote:
No, the last statement cannot result in a new assignment for the reference pointer. That's just unacceptable. That's why Frank was saying you needed "double pointers", so that you could specifically set the reference pointer to "nil" when you disposed it's corresponding store pointer.
Exactly. The other method would be fatal.
You could also search the reference pointers when disposing a store pointer, to find out which of these are affected, but that would be inefficient (like GC;-).
But it's done in several languages -- e.g. for interfaces in Delphi. There you don't have an explicit store pointer, but a reference counter keeps track on every piece of memory; if the number of pointers referencing it decreases to 0, it is automatically disposed of. This requires exactly what you say: Searching for all references to a piece of memory, whenever a pointer is set away from it.
Bye
Markus
Markus Gerwinski wrote:
But it's done in several languages -- e.g. for interfaces in Delphi. There you don't have an explicit store pointer, but a reference counter keeps track on every piece of memory; if the number of pointers referencing it decreases to 0, it is automatically disposed of. This requires exactly what you say: Searching for all references to a piece of memory, whenever a pointer is set away from it.
No, reference counting is not the same as keeping track of all references. You don't have to search the references (inefficiently), just change a counter.
Frank
Hi folks,
Frank Heckenbach wrote:
No, reference counting is not the same as keeping track of all references. You don't have to search the references (inefficiently), just change a counter.
Hmm, I see the point here. When setting pointer p from p1 to p2, we needn't know all other pointers referencing p1^ in order to decrease "refCount(p1^)" by 1. Okay.
Markus