Note that there are some explanatory texts on larger screens.

plurals
  1. POMemory leak in MongoDB cursor (OutOfMemory)?
    primarykey
    data
    text
    <p>This is how I'm reading my large MongoDB table (every object has very big chunks of data in its attributes):</p> <pre><code>DBCursor cursor = collection.find(/* my query */); while (cursor.hasNext()) { DBObject object = cursor.next(); doSomething(object); // no data stays in memory } cursor.close(); </code></pre> <p>I'm getting:</p> <pre><code>java.lang.OutOfMemoryError: Java heap space at java.lang.StringCoding$StringDecoder.decode(Unknown Source) at java.lang.StringCoding.decode(Unknown Source) at java.lang.String.&lt;init&gt;(Unknown Source) at org.bson.BasicBSONDecoder$BSONInput.readUTF8String(BasicBSONDecoder.java:463) at org.bson.BasicBSONDecoder.decodeElement(BasicBSONDecoder.java:155) at org.bson.BasicBSONDecoder._decode(BasicBSONDecoder.java:79) at org.bson.BasicBSONDecoder.decode(BasicBSONDecoder.java:57) at com.mongodb.DefaultDBDecoder.decode(DefaultDBDecoder.java:56) at com.mongodb.Response.&lt;init&gt;(Response.java:83) at com.mongodb.DBPort.go(DBPort.java:124) at com.mongodb.DBPort.call(DBPort.java:74) at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:286) at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:257) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:310) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:295) at com.mongodb.DBCursor._check(DBCursor.java:368) at com.mongodb.DBCursor._hasNext(DBCursor.java:459) at com.mongodb.DBCursor.hasNext(DBCursor.java:484) </code></pre> <p>Exception is thrown after 200-300 objects are processed. Does the driver holds data in memory? I'm using </p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;org.mongodb&lt;/groupId&gt; &lt;artifactId&gt;mongo-java-driver&lt;/artifactId&gt; &lt;version&gt;2.10.1&lt;/version&gt; &lt;/dependency&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload