Scenario:
After the system runs in the formal environment, it finds out that OOM (outofmemory) often occurs. After using windbg dump a few memories, it finds that many cache objects cannot be recycled. [a new description of the analysis process ], so how to handle the cache?
Solution:
Because the cache in the system uses hashtable to directly create keys and values to cache objects, which belongs to the strong handle type, of course, the first reaction is to create weakreference. So we re-constructed the cache based on this idea.
Ideas:
The cache base class bigcacheitem is based on weakreference. Other classes implement cache in different scenarios.
Class Name |
Purpose |
Bigfastcacheitem |
Quick cache of big data to reduce the waiting time for object Creation |
Fscacheitem |
File Cache. When a large object cannot be cached in the memory, it can be cached as a file. If necessary, the data can be retrieved again. |
Lightcacheitem |
Lightweight cache: This type is recommended when objects can be easily created. |
Let's get started with the code.
[Note]: many comments in the Code are automatically generated using ghostdoc, which is not verified and cannot be accurate.
Download source code:
/Files/alonesword/alonesword.component.cache.rar
Complete File Download:
Http://docs.google.com/View? Id = djsssq3_69gkvbmtcp