This web application is using Lucene.Net as its search engine, as a replacement for the FAST search implementation. A C# utility was written to create indices when new data becomes present, however, this application would steadily increase memory utilization up to 2GB. The rapid memory consumption was crippling our server. Rather than enjoying my first experiences in a new applications codebase, I had to figure out why this utility was eating memory.
After plenty of debugging and observations, I decided to improve memory management with our Lucene specific classes. All the objects were disposing properly. I made the objects disposable and destroyed or closed resources whenever possible. This did not make a difference in memory.
I finally came across a website where someone has seen similar issues. The site is translated from Chinese, but the message mentions that Lucene.Net will have memory leakage problems until the 1.9.1-001-13Jul06 version. If you must use a previous version, you can see a work-around solution on that site.
In code, as well as when using Microsoft's CLR Profiler, I was determining the source of the memory leak was in a compiled Lucene function, Lucene.Net.QueryParsers.QueryParser.Parse(query, searchField, analyzer). I would have to rebuild Lucene anyway if I were to fix it, so I decided to move to the latest version to save me the headache.
The version I am using now is 1.9.1.3 of Lucene.Net. This resolved my utility's memory consumption, and all is right in the world again. All too often I assume the code I am using from open-source or third party vendors is optimized and dependabl
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2009 MuellerDesigns.net
Sign In