Can someone give some examples of using weak references in .net projects ?
Think about cache with 2 levels. So objects in the 1st level are referenced with normal references and in then 2nd level with weak references. Thus if you want to expiry your object from the 1st level you can put it in the 2nd level.
Next time, when client tries to access this object if you have enough memory object will be promoted from the 2nd level, however if memory is not enough and object was collected you will have to recreate your object. Sometimes it will be recreated or retrieved from expensive store but in some situation you will be able to find it in the 2nd level.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With