[CDRIVER-394] memory leak with mongo tail api Created: 16/Jul/14  Updated: 11/Sep/19  Resolved: 16/Jul/14

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

Type: Task Priority: Critical - P2
Reporter: Arati Sethy Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: driver
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

linux



 Description   

I am using mongo TAILABLE cursor to read from mongod server. Notice that when the daemon is running for a long time , the process memory consumption keeps increasing. So used valgrind to check for memeory leak.
I get below out put from valgrind
-----------------------------------------------
==00:00:08:55.814 17673== 151,848 (123,120 direct, 28,728 indirect) bytes in 513 blocks are definitely lost in loss record 270 of 272
==00:00:08:55.815 17673== at 0x4C229FE: malloc (vg_replace_malloc.c:291)
==00:00:08:55.815 17673== by 0x4E3104C: bson_malloc (bson.c:952)
==00:00:08:55.815 17673== by 0x4E3735F: mongo_find (mongo.c:1243)
==00:00:08:55.815 17673== by 0x40482A: start_threshold_mongo_log_tailable (mongotosqlite_main.c:481)
==00:00:08:55.815 17673== by 0x619AFC6: start_thread (in /lib64/libpthread-2.8.so)
==00:00:08:55.815 17673== by 0x6A097AC: clone (in /lib64/libc-2.8.so)
==00:00:08:55.815 17673==
==00:00:08:55.815 17673== 745,644 (599,280 direct, 146,364 indirect) bytes in 2,497 blocks are definitely lost in loss record 271 of 272
==00:00:08:55.815 17673== at 0x4C229FE: malloc (vg_replace_malloc.c:291)
==00:00:08:55.815 17673== by 0x4E3104C: bson_malloc (bson.c:952)
==00:00:08:55.815 17673== by 0x4E3735F: mongo_find (mongo.c:1243)
==00:00:08:55.815 17673== by 0x4050A8: start_mongo_log_tailable (mongotosqlite_main.c:724)
==00:00:08:55.815 17673== by 0x619AFC6: start_thread (in /lib64/libpthread-2.8.so)
==00:00:08:55.815 17673== by 0x6A097AC: clone (in /lib64/libc-2.8.so)
==00:00:08:55.815 17673==
--------------------------------------------------------------------------------------------
Following is the code snippet.
while(1)
{
if(mongo_check_connection (my_client) == MONGO_ERROR )

{ closeMongoConnection(log_type); syslog(LOG_LOCAL0, "Mongo db connection lost for log type: %d Reconnecting",log_type); my_client = create_mongo_client(log_type,table_name); }

cursor = mongo_find( my_client,table_name , &b, bson_empty( &e ), 0, 0, MONGO_TAILABLE);
.....
}// end of mongo_check_connection (my_client)
bson_destroy( &b );
bson_init( &b );
bson_append_start_object( &b, "_id" );
bson_append_oid( &b, "$gt", &id );
bson_append_finish_object( &b );
bson_finish( &b );
}
------------------------------------------------------
Can you please advise what is the issue and how to fix?
I thought of upgrading to latest c-driver. But my application runs on 32 bit system.
Please assist.



 Comments   
Comment by Christian Hergert [ 16/Jul/14 ]

Marking duplicate of CDRIVER-395

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