jamesmontemagno / monkey-cache

Easily cache any data structure for a specific amount of time in any .NET application.
MIT License
670 stars 106 forks source link

App takes up over 100% CPU after Barrel.Current.Get #101

Closed EeeDotZee closed 3 years ago

EeeDotZee commented 3 years ago

First of all thank you for the great library James. I have one problem with it though which currently makes it unusable for me. Basically my use case is caching files up to 300kb in the Barrel (I store objects containing some information fields and the large byte array). On iOS if i cache files, restart the App and then access the files again with Barrel.Current.Get the CPU usage of the app jumps up to over 100% and doesn't go down until i close the app again. This only happens after a restart. Additionally it doesn't happen if I'm caching small information files. I'm absolutely sure that the CPU spike is caused by the Barrel call, as soon as i deactivate the Barrel call and use dummy data instead the CPU spike does not occur.

Is my use case simply not fitting for this library?

PS: I tried all 3 different implementations of MonkeyCache (LiteDB, SQLite, FileStorage)

EDIT: I found the problem: In the object strucutre that i cached in the Barrel i had a ManualResetEvent (which makes no sense to put in the cache actually). After setting this to ManualResetEvent to null the problem doesnt occur anymore.

pamela032709 commented 1 year ago

did you find out why ?