when using Lucene to build an index, the IndexWriter object is too large to lead to memory overflow, but my IndexWriter has been created by declaring temporary variables, but after each execution of the IndexWriter.addDocument () method, the size of the object will accumulate on the size of the previously established index, and because of the large amount of data, the IndexWriter object is getting bigger and bigger.