I am using Lucene NET v4.8 beta, and I have noticed that my service consume more and more memory whenever I add huge amounts of data to the index.
I analyzed this through dotMemory, seen below. The spike of memory at minute 4 is when I added a bunch of data to the Index. I understand the increase in gen0 memory because I am creating IndexWriter
object and performing write/commit operations. However, it seems as if, once the GC is called, the gen0
objects it collects becomes part of unmanaged memory
instead (for example, at minute 5:30 in the screenshot, we can see that gen0
memory usage got collected, but total memory
remained the same - unmanaged memory
grew the same amount that gen0
memory got collected).
I have already implemented the Dispose pattern in my code properly for IndexWriter
and IndexReader
, but this issue remains. The only 'fix' I was able to do I was able to do was forcing Garbage Collect to collect, via GC.Collect()
manually in the code, but it still doesn't remove all the extra unmanaged memory.
My questions are, what is causing Lucene NET to behave like this (turning gen0 objects into unmanaged resources)? And is there a way to fix this without having to do GC.Collect()
every so often?