[CDRIVER-478] mongoc_collection memory leak reported by Xcode Instruments Created: 06/Dec/14  Updated: 03/May/17  Resolved: 02/Oct/15

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: 1.0.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Tim Dorcey Assignee: Hannes Magnusson
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

On OSX 10.10 the XCode Instruments Memory Leak profiling tool reports a 16-byte memory leak for every mongoc_collection_get/destroy sequence. The tool attributes the leak to mongoc_buffer_destroy(). The sequence to reproduce is:
mongoc_init();
mongoc_client_t *client = mongoc_client_new("mongodb://localhost:27017/");
mongoc_collection_t *collection = mongoc_client_get_collection(client, "testdb", "testco");
mongoc_collection_destroy(collection);
mongoc_client_destroy(client);
mongoc_cleanup();

This seems like such a fundamental sequence, possibly the profiling tool is in error?



 Comments   
Comment by Hannes Magnusson [ 02/Oct/15 ]

Closing this issue as "Cannot Reproduce".

If you can still reproduce this, please attach the full report from XCode Instruments so we can see the entire chain.
It might be a bug in the tool?

Note that there are certain known leaks/still reachable in both OpenSSL and CyrusSASL in certain scenarios. These are intentional by the respective libraries and should be ignored.
Have a look at our valgrind suppression file: https://github.com/mongodb/mongo-c-driver/blob/master/valgrind.suppressions

Comment by Hannes Magnusson [ 17/Aug/15 ]

timful I'm not able to reproduce this using Valgrind, and looking at the code I can't see a path where it collection->buffer would leak (which I am assuming it is complaining about).

cat ex.c
#include <mongoc.h>
int main(int argc, char** argv) {
   mongoc_init();
   mongoc_client_t *client = mongoc_client_new("mongodb://localhost:27017/");
   mongoc_collection_t *collection = mongoc_client_get_collection(client, "testdb", "testco");
   mongoc_collection_destroy(collection);
   mongoc_client_destroy(client);
   mongoc_cleanup();
   return 0;
}

Can you attach the full report?

Comment by Chengcheng Pei [ 25/Feb/15 ]

I have the same issue.
http://stackoverflow.com/questions/28724630/mongoc-init-and-mongoc-cleanup-may-make-memory-still-reachable

Generated at Wed Feb 07 21:09:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.