Memory leak in MongoDB cursor (OutOfMemory)?

前端 未结 1 1324
暗喜
暗喜 2021-01-14 00:57

This is how I\'m reading my large MongoDB table (every object has very big chunks of data in its attributes):

DBCursor cursor = collection.find(/* my query *         


        
相关标签:
1条回答
  • 2021-01-14 01:41

    The number of objects the driver will hold in memory depends on the cursor's batch size. I'm not sure what the default batch size is when you don't set one explicitly. Depending on the maximum size of your documents and the amount of heap space available, you should set the batch size accordingly. Keep in mind that the current maximum document size supported by MongoDB is 16MB.

    See DBCursor.batchSize() in the MongoDB Java driver API docs for details.

    0 讨论(0)
提交回复
热议问题