I found out that my program is taking substantially more memory than I expected, so I profiled it. Through eventlog2html, I found that it was taking 87MB while maximum live bytes was just 5 MB bytes!
I wondered how, searched a bit and found out that pinned bytestring
could fix the memory in place and cause fragmentation.
Then, I checked with -Dg
and got the following data.
Memory inventory:
gen 0 blocks : 23 blocks ( 0.1 MB)
gen 1 blocks : 140 blocks ( 0.5 MB)
nursery : 16400 blocks ( 64.1 MB)
empty pinned : 16400 blocks ( 8.0 MB)
retainer : 0 blocks ( 0.0 MB)
arena blocks : 48 blocks ( 0.2 MB)
exec : 0 blocks ( 0.0 MB)
GC free pool : 31 blocks ( 0.1 MB)
free : 2234 blocks ( 8.7 MB)
UpdRemSet : 0 blocks ( 0.0 MB)
total : 20916 blocks ( 81.7 MB)
What does this mean? “empty pinned” means memory that cannot be deallocated due to pinned memory, right?
How do I debug this circumstances and avoid the wastage of memory?