I have a graph of the structure. I do not know that instead of destroying objects in traditional Delphi methods, I count the reference I want to apply anything like items. I know that I can use something like an object. Getreferences and Objects Released instead of free, and use a personal variable for reference count, but is there any better way?
Thanks
If you have the right way to destroy standard objects in the Delphi program There is a problem determining (location, order, and so on), this will not help you in the context of gilt objects or interfaces using context.
I understand that you want to keep the nodes in each other's references in the graph, and when you do not leave any reference in an object, then it should be automatically deleted but consider the fact Please note that each node can be referenced in two nodes, and the referee counting will not return again, so that those objects can not be freed. You will need to break at least one reference / dependency manually. And if you have to do this, you can leave the reference count completely. See Wikipedia articles for more information. Interfaces can be used in Delphi for reference calculations, but weak references can only be maintained with clever type casting. See for an example.
An idea that you want to expert, is to maintain standard lifetime management for your objects, and keep track graphs instead of dependency.
Each graph object should have a list of other objects that have connections with. Now you can free any object, and remove all references that are destroyed by the housekeeping code, all other items of the object for the list. If you want to modify the graph, you can only empty the nodes you want to delete, and the dependencies will be updated. If you want to delete the whole graph, then just delete all the nodes. Basically you have a list of nodes (ownership, lifetime management) and other data structure to describe the graph.
Comments
Post a Comment