-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.11.2, 2.12.0
-
Component/s: Query Operations
-
Labels:None
-
Environment:java 1.6 and mongodb driver 2.11.2
when I use this command to query the oplog of MongoDB, I got out of memory issue.
cursor = oplogColl.find(query).sort(new BasicDBObject("$natural", 1)).addOption(Bytes.QUERYOPTION_TAILABLE).addOption(Bytes.QUERYOPTION_AWAITDATA);
and through a iterator to get all operation logs.
DBObject data = cursor.next();
Exception description
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2734)
at java.util.ArrayList.ensureCapacity(ArrayList.java:167)
at java.util.ArrayList.add(ArrayList.java:351)
at com.mongodb.DBApiLayer$Result.init(DBApiLayer.java:369)
at com.mongodb.DBApiLayer$Result._advance(DBApiLayer.java:429)
at com.mongodb.DBApiLayer$Result.hasNext(DBApiLayer.java:396)
at com.mongodb.DBCursor._hasNext(DBCursor.java:464)
at com.mongodb.DBCursor.hasNext(DBCursor.java:484)
at com.patsnap.mongodb.dataload.MongoDbDataLoader.hasNext(MongoDbDataLoader.java:128)
at com.patsnap.mongodb.dataload.MongoDbDataLoader.main(MongoDbDataLoader.java:86)
the reason is that the size type is List<Integer>, It will become big enough if you iterator more data and eventually out of memory
_sizes.add( res.size() );