I have found some old posts on stackoverflow regarding the problem of a memory leak with the php mongodb driver. But none gave a final solution or explenation for older versions of the php mongodb driver or for the version I am using.
Also the driver changelog does not show any recent updates regarding a memory leak.
My Version of the Driver is 1.4.5 (stable) with PHP 5.3.10
Code with Debug echos:
echo memory_get_usage()." in MB : ";
echo memory_get_usage()/1024/1024;
echo "<br>";
unset($cursor);
$dt = new DateTime($day." 00:00:00", new DateTimeZone($this->timezone));
$mongodate = new MongoDate($dt->getTimestamp());
// print_r($mongodate);
$cursor = $dc->findOne(array('keyword' => $keyword, 'date' => $mongodate));
echo "Cursor loaded Doc (".$cursor['_id'].") : ";
echo memory_get_usage()." in MB : ";
echo memory_get_usage()/1024/1024;
echo "<br>";
** Echos True Memory Usage**
3932160 in MB : 3.75
Cursor geladen Doc (534cdee3c30fd1b8ee0bb641) : 218305980 in MB : 208.1928062439
Code with Debug echos True Memory Usage:
echo memory_get_usage(true)." in MB : ";
echo memory_get_peak_usage(true)/1024/1024;
echo "<br>";
unset($cursor);
$dt = new DateTime($day." 00:00:00", new DateTimeZone($this->timezone));
$mongodate = new MongoDate($dt->getTimestamp());
// print_r($mongodate);
$cursor = $dc->findOne(array('keyword' => $keyword, 'date' => $mongodate));
/*
echo "<pre>";
print_r($cursor);
echo "</pre>";
*/
echo "Cursor loaded Doc (".$cursor['_id'].") : ";
echo memory_get_usage(true)." in MB : ";
echo memory_get_peak_usage(true)/1024/1024;
echo "<br>";
** Echos True Memory Usage**
3932160 in MB : 3.75
Cursor loaded Doc (534cdee3c30fd1b8ee0bb641) : 218628096 in MB : 224.5
So only one Documents causes an encrease by over 200 MB of memory.
bitrs3:PRIMARY> var doc = db.dailies.findOne({"_id" : ObjectId("534cdee3c30fd1b8ee0bb641")})
bitrs3:PRIMARY> Object.bsonsize(doc)
16754823
The document loaded is truely not small, it has 16754823 Bytes so reaches the maximum Bson Size of 16 MB
Still I am wondering if it is normal that the findOne + cursor operation which creates an array out of the results needs so much memory.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/17f35f49-e487-474d-9f22-59c18d13439a%40googlegroups.com.--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.