I uploaded my new WeakObjectReferences unit for Delphi 2009-XE4 that doesn't need a HashTable+ArrayList+global lock. It requires 36 bytes per object if WeakReferences exist no matter how many WeakReferences to the one object exist.

I uploaded my new WeakObjectReferences unit for Delphi 2009-XE4 that doesn't need a HashTable+ArrayList+global lock. It requires 36 bytes per object if WeakReferences exist no matter how many WeakReferences to the one object exist.

Have a look and tell me what you think.
https://github.com/ahausladen/WeakObjectReferences

Comments

  1. Andreas' stuff must be cool, but can anyone explain when should I use it? Thanks!

    ReplyDelete
  2. If weak pointers were wrapped (indirection), then a list could be avoided, and clearing the wrap in a single set to nil will act as clearing all references? (and will work fast)

    ReplyDelete
  3. David Berneda but then wouldn't that just displace the problem to that of managing the indirection object/buffer, which will need to be distinct from both the weak referenced and the referenced object? It could be lock-free, but AFAICT you would need a thread to perform the GC of those indirection (and if you use a GC thread, you might as well do away with weak references entirely and use it to collect cycles, this would eliminate all the overhead of weak references)

    ReplyDelete

Post a Comment