rclabo commented on issue #784: URL: https://github.com/apache/lucenenet/issues/784#issuecomment-1359441519
Hi @PeterOeClausen - Thanks for sharing your code for your two approaches. This helps alot. I'm not so sure that the memory differences you are seeing have anything to do with LuceneNET per se. The key reason you see so much memory allocation with `writer.AddDocuments` is that the `documentList` you are passing has a million documents in it. So this memory allocation is happening simply due to building the `documentList` even if you never call `writer.AddDocuments`. If you were calling `writer.AddDocuments` with a list of 10 documents and called that in a loop 100,000 times then the memory allocations would be much closer to what you are seeing by calling `writer.AddDocument` with a single document done 1 million times. One final note, even for the `writer.AddDocument` case you can reduce allocations further if you like. You can use the same `Document` over and over by settings it's values before calling `writer.AddDocument` . In this way there is only ever one `Document` allocated rather then 1 millions that eventually need to be garbage collected. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@lucenenet.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org