c# - Runtime.Caching.MemoryCache throws OutOfMemoryException when add many item to cache -


for heavy calculation want to put temp results memorycache , load again when required. when put 2 million object cache, throws outofmemoryexception.

i run program on windows 7 64 bit 8gb ram.

when task manager see application take 1.5 gb ram , crash. code similar in program

namevaluecollection config = new namevaluecollection {     {"cachememorylimitmegabytes", "4000"},     {"physicalmemorylimitpercentage", "100"} }; memorycache cache = new memorycache("mycache", config); cacheitempolicy policy = new cacheitempolicy { absoluteexpiration = objectcache.infiniteabsoluteexpiration }; (int = 0; < 4000000; i++) {     var resultoftempoperation = dooperation();     cacheitem newemployee = new cacheitem(guid.newguid().tostring(), new someclass());     cache.add(newemployee, policy); } 

what wrong in code?

in visual studio go

solution>properties>configuration properties>platform

make sure compiling x64 if need use memory. (you hitting 32bit limit)


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -