EFInteractiveViews icon indicating copy to clipboard operation
EFInteractiveViews copied to clipboard

High utilisation of memoy

Open sekar79 opened this issue 8 years ago • 5 comments

I use this library in my project. I have more than 600 tables in my application. I split them into multiple contexts. This loads all the views into the memory and it consumes more than 500MB of server memory. Why is it keeping the views in the memory?

sekar79 avatar Apr 27 '17 17:04 sekar79

This is not specific to this library but to EF. Any EF query/command (besides SqlQuery/SqlCommand which bypass EF pipeline) requires views. This is library is just caching views generated by EF and loading them at startup to improve the start up time. Without the library EF would have to generate the views each time the application starts (on first request) and with 600 tables it can actually make a difference but the views are exactly the same so memory usage will be the same. If you however see a difference in memory between when using EFInteractive views and when not using EFInteractive views let me know, and possibly provide dumps.

moozzyk avatar Apr 27 '17 18:04 moozzyk

thanks. I have memory dump file but it is 1.2 GB. How would i upload this to you? When i selected heap view, it shows like this. ConcurrentDictionary<DbMappingViewCacheFactory, StorageMappingItemCollection> 279 MB ConcurrentDictionary+Tables<DbMappingViewCacheFactory, StorageMappingItemCollection> 279 MB ConcurrentDictionary+Node<DbMappingViewCacheFactory, StorageMappingItemCollection> 279 MB StoragemappingItemCollection 279 MB.

sekar79 avatar Apr 27 '17 19:04 sekar79

That would be here. Can you check if anything else is holding on to this instance of StorageMappingItemCollection? It's been a while since I wrote this code so I don't remember why I need to keep this but it might be an actual leak if the only thing that keeps the storageMappingItemCollection alive is the dictionary. I will try to look into this in the coming days to see if the mapping item collection can be cleaned somehow when it is no longer used.

moozzyk avatar Apr 27 '17 20:04 moozzyk

Any idea why it keeps multiple instance of dictionary object? Shall i dispose the dictionary object after instantiating it?

sekar79 avatar May 07 '17 07:05 sekar79

I have not had a chance to look at this yet. Sorry.

moozzyk avatar May 08 '17 15:05 moozzyk