Removing items from reliable dictionary doesn't actually remove them from memory

こ雲淡風輕ζ 提交于 2019-12-08 00:02:11

问题


I'm having statefull service, and I'm using reliable dictionary as a work item store. Code-wise:

var workItemStore = 
  this.StateManager.GetOrAddAsync<IReliableDictionary<TKey, TValue>>(storeName);

Debugging internals shows this is a returns a wrapper over DistributedDictionary class, that is using TStore class to do heavy lifting.

I have a work item processor (kind of like queue), in which I'm adding values to this store (workItemStore) and after I'm done I'm removing them. However when I make memory dump I still can see the old (removed) keys and values to be present even after explicitly GC.Collect().

Sample memory dump:

Object type                       |     Count | Size (Bytes) | Inclusive Size (Bytes)
-------------------------------------------------------------------------------------
LockManager                       |    10,635 |   53,526,856 | 511,008,280
ReaderWriterLockSlim              | 2,772,648 |  261,374,208 | 248,745,216
TStore<Guid, WorkItem, ...>       |     3,236 |   15,999,256 | 216,851,864
Dictionary<UInt64, LockHashValue> | 2,772,560 |  217,807,600 | 207,288,816

Drilling down LockManager, ReaderWriterLockSlim and Dictionary<UInt64, LockHashValue> points to values in TStore.

Is there a way how to force cleanup of items from IReliableDictionary (i.e. remove removed items from memory) ?


回答1:


After digging into this the problem is that removal is only logical removal - it doesn't actually remove items from memory. The removal should happen eventually though when in-memory changes are serialized to disk.



来源:https://stackoverflow.com/questions/47776645/removing-items-from-reliable-dictionary-doesnt-actually-remove-them-from-memory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!