mbdavid / LiteDB

LiteDB - A .NET NoSQL Document Store in a single data file
http://www.litedb.org
MIT License
8.52k stars 1.24k forks source link

Fixed memory leak due to infinite static caches #2438

Closed Sasha-hi closed 2 months ago

Sasha-hi commented 7 months ago

Use MemoryCache with fixed SlidingExpiration. Increasing the required framework version to 4.5.1 Not the best solution, but better than endlessly eating up memory

2421

Sasha-hi commented 4 months ago

Revert all changes. Now, no new dependency Default logic does not change - indefinite cache

JKamsker commented 3 months ago

Although I am not 100% sure, I am afraid this cache does not solve the problem. The problem is that lambda.compile generates a delegate to something that might be an interpreted expression or real IL code that is actually executed. In the latter case, removing the reference to the delegate would not cause any relief in the memory pressure.

Would you mind providing unit tests and benchmarks (+results)?

JKamsker commented 2 months ago

I think the problem this pr addresses is real but its really not solved with this pr. I am going to close it for now. Feel free to reopen it at any time.