memory-fragmentation

Heap fragmentation when using byte arrays

橙三吉。 提交于 2019-12-03 01:47:15
I have a C# 4.0 application (single producer/single consumer) which transfers huge amount of data in chunks. Although there's no new memory allocation I run out of memory after a while. I profiled memory using Redgate memory profiler and there are a lot of free memory there. It says free memory cannot be used because of fragmentation. I use a blocking collection as the buffer and byte arrays as the members: BlockingCollection<byte[]> segments = new BlockingCollection<byte[]>(8); // producer: segments.Add(buffer); // consumer: byte[] buffer = _segments.Take(); How can I avoid managed memory

Can “pragma pack 1” be helpful to avoid heap fragmentation?

坚强是说给别人听的谎言 提交于 2019-12-01 16:09:50
In my program I see some resident size increase. I suppose it is because of heap fragmentation. So I am planning to use #pragma pack 1 . Will it reduce the heap fragmentation? Will it be having some other overheads? Shall I go for it or not? Packing structures probably won't have much affect on heap fragmentation. Heap fragmentation normally occurs when there is a repeating pattern of allocations and freeing of memory. There are two issues here, one issue is that the virtual address space gets fragmented, the other issue is that physical 4k pages end up with unused gaps, consuming increasing

Can “pragma pack 1” be helpful to avoid heap fragmentation?

匆匆过客 提交于 2019-12-01 15:14:06
问题 In my program I see some resident size increase. I suppose it is because of heap fragmentation. So I am planning to use #pragma pack 1 . Will it reduce the heap fragmentation? Will it be having some other overheads? Shall I go for it or not? 回答1: Packing structures probably won't have much affect on heap fragmentation. Heap fragmentation normally occurs when there is a repeating pattern of allocations and freeing of memory. There are two issues here, one issue is that the virtual address