summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2014-03-20 09:41:30 -0400
committerBenety Goh <benety@mongodb.com>2014-03-20 13:06:47 -0400
commitb9da5eed52b63d721d78bf76d58b4b8a6b6b8703 (patch)
treec96bb98839d00b2b1ee4079b26edfa4402fecdc6
parent4b1e555f6b0ffd027e4c54f3b7034a4b8fb4ec1e (diff)
downloadmongo-b9da5eed52b63d721d78bf76d58b4b8a6b6b8703.tar.gz
SERVER-13293 fixed geo filter memory leak when creating index scan/fetch stages
(cherry picked from commit b03ec74111f0dc839d14bacf3f12267133cbc935)
-rw-r--r--src/mongo/db/exec/s2near.cpp9
-rw-r--r--src/mongo/db/exec/s2near.h3
2 files changed, 9 insertions, 3 deletions
diff --git a/src/mongo/db/exec/s2near.cpp b/src/mongo/db/exec/s2near.cpp
index 74d0582ce39..55b6274f2d6 100644
--- a/src/mongo/db/exec/s2near.cpp
+++ b/src/mongo/db/exec/s2near.cpp
@@ -274,9 +274,11 @@ namespace mongo {
//
// This does force us to do our own deduping of results, though.
params.doNotDedup = true;
- GeoS2KeyMatchExpression* me = new GeoS2KeyMatchExpression(
- &_annulus, _params.baseBounds.fields[_nearFieldIndex].name);
- IndexScan* scan = new IndexScan(params, _ws, me);
+
+ // Owns geo filter.
+ _keyGeoFilter.reset(new GeoS2KeyMatchExpression(
+ &_annulus, _params.baseBounds.fields[_nearFieldIndex].name));
+ IndexScan* scan = new IndexScan(params, _ws, _keyGeoFilter.get());
// Owns 'scan'.
_child.reset(new FetchStage(_ws, scan, _params.filter));
@@ -289,6 +291,7 @@ namespace mongo {
// All done reading from _child.
if (PlanStage::IS_EOF == state) {
_child.reset();
+ _keyGeoFilter.reset();
// Adjust the annulus size depending on how many results we got.
if (_results.empty()) {
diff --git a/src/mongo/db/exec/s2near.h b/src/mongo/db/exec/s2near.h
index 4c84d547253..054b4cce16f 100644
--- a/src/mongo/db/exec/s2near.h
+++ b/src/mongo/db/exec/s2near.h
@@ -91,6 +91,9 @@ namespace mongo {
// bounds for the various annuluses/annuli.
int _nearFieldIndex;
+ // Geo filter in index scan (which is owned by fetch stage in _child).
+ scoped_ptr<MatchExpression> _keyGeoFilter;
+
scoped_ptr<PlanStage> _child;
// The S2 machinery that represents the search annulus. We keep this around after bounds