Debugging Memory Issues with RavenDB using WinDBG
Join the DZone community and get the full member experience.Join For Free
we had gotten a database export that showed a pretty rough case for ravendb. a small set of documents (around 7k) that fan out in multiple map/reduce indexes to be around 70k to 180k (depending of which index is used).
as you can imagine, this puts quite a load on the system, i tried to use the usual methods (dottrace, hand picking, etc) and we did get some good results on that, we found some pretty problematic issues along the way, and it was good. but we still had the ravendb process take way too much memory. that means that we had to pull the big guns, windbg.
i took a dump of the process when it was using about 1 gb of memory, then i loaded that dump into windbg (6.2.9200.20512 amd64).
i loaded sos:
.loadby sos clr
then, the first thing to do was to try to see what is going on with the threads:
as you can see, we have a small number of threads, but nothing to write home about. the next step is to see if we have anything very big in the heap:
the first number is the method table address, the second is the count, and the third is the total size. the problem is that all of that combine doesn’t reach near as much memory as we take.
i guess it is possible that we hold a lot of data in the stack, especially since the problem is likely caused by indexing.
i decided to map all of the threads and see what they are doing.
switches me to thread #1, and we can see that we are currently in a waiting. dumping the stack reveals:
this seems to be the debugger thread. let us look at the rest:
- 2 – finalizer
3 – seems to be an inactive thread pool thread.
6 – appears to be an esent thread:
i am not sure what this is doing, and i am going to ignore this for now.
7 – also esent thread:
and… i got tired of this, and decided that i wanted to do something more productive, which is to selectively disable things in ravendb until i find something that drops the memory usage enough to be worth while.
whack a mole might not be a great debugging tool, but it the essence of binary search. or so i tell myself to make my conscience sleep more easily.
for reference, you can look at the dump file here .
Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.