Heap fragmentation is a state in which available memory is broken into small, noncontiguous blocks. When a heap is fragmented, memory allocation can fail even when the total available memory in the heap is enough to satisfy a request, because no single block of memory is large enough.
Instead of allocating objects in the heap, we place them in the stack or in the globals. By design, these two areas are not fragmented. For example, we could replace all String objects with plain old char[] . Not only we would reduce the fragmentation, but we would also create a smaller and faster executable.
You can measure fragmentation directly by looking at /proc/buddyinfo which will tell you how many free chunks are available on each zone of each NUMA node per each order. You can do a little math and calculate what percentage of free memory is available for allocations of a certain order.
Definition. Fragmentation of memory is a type of memory disruption pertaining to the flaws or irregularities in sequences of memories, "coherence, and content” in the narrative or story of the event. During a traumatic experience, memories can be encoded irregularly which creates imperfections in the memory.
0:000> !dumpheap -stat
total 1755874 objects
Statistics:
MT Count TotalSize Class Name
7b9b0c64 1 12 System.Windows.Forms.Layout.TableLayout+ColumnSpanComparer
....
7933303c 14006 4926456 System.Collections.Hashtable+bucket[]
65246e00 804 4982192 System.Data.RBTree`1+Node[[System.Int32, mscorlib]][]
054c55f0 44240 5662720 DevExpress.Utils.AppearanceObject
793040bc 98823 7613156 System.Object[]
793308ec 293700 55820016 System.String
002435f0 50315 138631888 Free
Total 1755874 objects
Fragmented blocks larger than 0.5 MB:
Addr Size Followed by
15a195c8 0.8MB 15ae3950 System.Collections.ArrayList
15d81468 1.6MB 15f23708 System.String
15f23984 1.0MB 16029ae4 System.String
... about 7 more objects here
1ee51764 0.5MB 1eedbaa4 System.WeakReference
1f0df96c 2.4MB 1f34d4b0 System.String
1f3e1ca8 3.7MB 1f79afc4 System.WeakReference
I've been reading about pinning and fragmentation. Its looking fragmented to me given the massive amount of free space. I guess I have to now track it down.
Thoughts? feedback?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With