[SERVER-8170] v8 leaks several external objects Created: 14/Jan/13  Updated: 11/Jul/16  Resolved: 01/Mar/13

Status: Closed
Project: Core Server
Component/s: JavaScript
Affects Version/s: 2.3.2
Fix Version/s: 2.4.0-rc2

Type: Bug Priority: Major - P3
Reporter: Ben Becker Assignee: Ben Becker
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File dbclient_memleak.patch    
Operating System: ALL
Steps To Reproduce:

Paste code from description into shell, or into dbEval.

Participants:

 Description   

This was encountered while debugging a memory leak in v8, and can be reproduced in the shell or server w/ db.eval().

var mongo = new Mongo();
for (var i = 0; i<10000; i++) {
    var res = mongo.find("test.a", {b:new Array(10240).toString()}, {a:1}, 0, 0, 0, 0);
}
gc();



 Comments   
Comment by auto [ 01/Mar/13 ]

Author:

{u'date': u'2013-03-01T18:40:05Z', u'name': u'Ben Becker', u'email': u'ben.becker@10gen.com'}

Message: SERVER-8170: free all external JavaScript resources on V8Scope destruction
Branch: master
https://github.com/mongodb/mongo/commit/77d55de67cf5700a4472d60ed2df4d7b5157de95

Comment by auto [ 27/Feb/13 ]

Author:

{u'date': u'2013-02-27T20:16:32Z', u'name': u'Ben Becker', u'email': u'ben.becker@10gen.com'}

Message: SERVER-8170: manually free external resources upon V8Scope destruction
Branch: master
https://github.com/mongodb/mongo/commit/5637ebbc1c778d55dc105a3dc8c6d016523d095e

Comment by Ben Becker [ 26/Feb/13 ]

Updating this ticket to track v2.4-specific leaks, as the v2.0.7 leaks are related to holding onto client cursors.

Comment by auto [ 12/Feb/13 ]

Author:

{u'date': u'2013-02-12T19:13:35Z', u'name': u'Ben Becker', u'email': u'ben.becker@10gen.com'}

Message: SERVER-8170: cleanup and unify GC callbacks
Branch: master
https://github.com/mongodb/mongo/commit/75b0536f0032627241fbad47baba64322834e523

Comment by Ben Becker [ 25/Jan/13 ]

Attaching dbclient_memleak.patch to reproduce the observed behavior. Reproducible by simply passing a BSONObj to the query() method. Apply with patch -p1 < dbclient_memleak.patch. This patch reflects the issue that was observed, but only because it calls auto_ptr::release() without explicitly freeing the object. This seems to indicate that we either:

  1. Aren't removing all references to the cursor returned by mongoFind()
  2. V8 does not release the allocated memory back to the OS on v8::V8::LowMemoryNotification()
Generated at Thu Feb 08 03:16:44 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.