How to list a 2 million files directory in java without having an “out of memory” exception

后端 未结 15 1840
挽巷
挽巷 2020-12-06 00:04

I have to deal with a directory of about 2 million xml\'s to be processed.

I\'ve already solved the processing distributing the work between machines and threads us

15条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-06 00:22

    As a first approach you might try tweaking some JVM memory settings, e.g. increase heap size as it was suggested or even use AggressiveHeap option. Taking into account the large amount of files, this may not help, then I would suggest to workaround the problem. Create several files with filenames in each, say 500k filenames per file and read from them.

提交回复
热议问题