Reputation: 601
I have a WPF (C# 3.5) app which have tons of threads... lately my threads are getting stuck on ThreadWaitReason PageIn (I've managed to discover it using Memory Profiler). Tough I can understand the message I`m not sure on what it really means, and how can I avoid/workaround this problem... Your help is really appreciated! Thank you so much!
Statistics
Memory consumption: 456mb
Private bytes: 364mb
.NET private bytes usage: 150mb
ProcessThreads: 76 (all of them are in wait state, threadwaitreason: pagein
The tool is warning a message: "Memory fragmentation is restricting the size of objects that can be allocated."
Upvotes: 3
Views: 549
Reputation: 62459
If you use up all of your available physical memory, you will end up paging to the disk which takes an enormous amount of time to read a page compared to the RAM. This is why your threads are waiting for pages to be loaded.
The warning you are mentioning is due to the fact that allocations and deallocations of memory result in the memory being fragmented with gaps between chunks of free memory. If the fragmentation is severe, the free chunks may be so small that you are not able to freely allocate memory as you wish.
Upvotes: 1