Questions tagged [weak-references]
4 questions
62
votes
6 answers
When to use weak references in .Net?
I have not personally come across a situation where I've needed to use WeakReference type in .Net, but the popular belief seems to be that it should be used in caches. Dr Jon Harrop gave a very good case against the use of WeakReferences in caches…
theburningmonk
- 731
3
votes
3 answers
What use is a non-zeroing weak reference?
When reading about the various options for working with things like ARC / GC, I often come across explicit wording about which weak references are zeroing (ie, your reference becomes nil/null/0 when the object is collected) and which non-zeroing…
Sophistifunk
- 131
- 4
1
vote
1 answer
De facto weak reference centralized object storage
In a PHP CLI software, we are facing serious memory leakage due to a lot of rotten code, both accumulated in our own software and third-party plugins for our software.
Currently, the object references look like this:
class Server{
// the central…
SOFe
- 728
- 1
- 7
- 28
0
votes
1 answer
Why is `WeakSet` great for tracking circular references?
In MDN article on WeakSets, an example is given for using weak sets to avoid infinite recursion on circular references:
// Execute a callback on everything stored inside an object
function execRecursively(fn, subject, _refs = new WeakSet()) {
//…
Anton Strogonoff
- 145