Long-Running Async and Memory Fragmentation
Join the DZone community and get the full member experience.Join For Free
we are working on performance a lot lately, but performance isn’t just an issue of how fast you can do something, it is also an issue of how many resources we use while doing that. one of the things we noticed was that we are using more memory than we would like to, and even after we were freeing the memory we were using. digging into the memory usage, we found that the problem was that we were suffering from fragmentation inside the managed heap.
more to the point, this isn’t a large object heap fragmentation, but actually fragmentation in the standard heap. the underlying reason is that we are issuing a lot of outstanding async i/o requests, especially to serve things like the changes() api, wait for incoming http requests, etc.
here is what this looks like inside dotprofiler.
as you can see, we are actually using almost no memory, but heap fragmentation is killing us in terms of memory usage.
looking deeper, we see:
we suspect that the issue is that we have pinned instances that we sent to async i/o, and that match what we have found elsewhere about this issue, but we aren’t really sure how to deal with it.
ideas are more than welcome.
Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.