out of memory exception

783 views
Skip to first unread message

Sarnam

unread,
Apr 30, 2012, 12:24:20 PM4/30/12
to mongodb-user
Hi,
I am using mongo C# driver version 1.4.1, but now using 1.4.2. its
working properly when 50 threads running concurrently. but it throw
exception "Out of memory exception" when more than 50 threads run
concurrently, mainly during bson deserialization (in embedded foeld
means nested document ), even returned data is in MB. So please help
me resolve this problem.

Thanks

Robert Stam

unread,
Apr 30, 2012, 1:47:39 PM4/30/12
to mongod...@googlegroups.com
We are not aware of any memory leaks in the C# driver, but will try to reproduce what you are describing.

If you could post a complete program that reproduces the issue that would speed up the process a lot.

What operating system are you running on and is it 32-bit or 64-bit? If you are on a 32-bit operating system you might just actually be running out of memory.


--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.


A. Jesse Jiryu Davis

unread,
Apr 30, 2012, 1:55:01 PM4/30/12
to mongod...@googlegroups.com
Sarnam, can you reproduce this exception both in version 1.4.1 and 1.4.2, or is this a new problem with 1.4.2? Can you post an example C# program that reproduces the error? Additionally, can you show us some example documents and tell us the number of documents returned by each query?
To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.

Sarnam

unread,
May 1, 2012, 4:25:46 AM5/1/12
to mongod...@googlegroups.com
Thanks Robart / Jesse...
Further i am sending the details about what exactly i am doing..please have a look below..

Any help in this regard will be highly appreciated...

MongoDb implementation:

Here is the query i am using :

{ "FormId" : 2, "InsertedOn" : { "$gte" : ISODate("2012-03-31T18:30:00Z"), "$lte" : ISODate("2012-05-01T18:30:00Z") }, "FieldList" : { "$elemMatch" : { "FieldName" : "Name", "FieldValue" : /sarnam/i } } }
 
i am using 10 query like the above query means all queries only differing in one parameter ("FieldValue" : /sarnam/i ), using different strings in place of "sarnam". Database contains only 22000 documents and number of documents returned varies from 200 to 18000 records. and I initiated 50 or more threads to reproduce the bug "Out of memory exception".

     Application is running on windows 7 64 bit operating system.



 public List<DynamicFormData> ExecuteQuery(object queryExpression_)
        {
            List<DynamicFormData> retObject = null;
            IMongoQuery qry = (IMongoQuery)queryExpression_;
            MongoDatabase db = server.GetDatabase(databaseName);
            DependencyResolver.Current.GetService<ILoggingService>().Info("Execute Query With Server State :" + db.Server.State);
            try
            {
                using (server.RequestStart(db))
                {
                    MongoCollection collection = db.GetCollection(typeof(DynamicFormData).ToString());
                    retObject = collection.FindAs<DynamicFormData>(qry).ToList<DynamicFormData>();
                    DependencyResolver.Current.GetService<ILoggingService>().Info("Query Executed@@@@@@@ Server Sarnam :" + db.Server.State);
                }
            }
            catch (Exception ex)
            {
                DependencyResolver.Current.GetService<ILoggingService>().Info("Exception occured :" + db.Server.State + " **** Exception Details :" + ex.Message + "Stack Trace :" + ex.StackTrace);
            }
            //finally
            //{
                 
            //   // server.Disconnect();
            //}
          
            return retObject;
            
        }


Constructor class to register models:

 static MongoDBPersistenceService()
        {
            server =  GetConnection();
            BsonClassMap.RegisterClassMap<DynamicFormData>(cm =>
            {
                cm.AutoMap();
                cm.UnmapProperty(c => c.UserContent);
                cm.UnmapProperty(x => x.Tags);
            });
            BsonClassMap.RegisterClassMap<Site>();
            BsonClassMap.RegisterClassMap<DynamicForm>();
            BsonClassMap.RegisterClassMap<DynamicFormQuery>();
            BsonClassMap.RegisterClassMap<DynamicFormField>();
            
        }

Connection method:
 private static MongoServer GetConnection()
        {
            MongoServerSettings settings = new MongoServerSettings();
            settings.MaxConnectionLifeTime = new TimeSpan(0, 0, 180);
            settings.SafeMode = SafeMode.True;
            settings.SlaveOk = true;
            settings.ConnectionMode = ConnectionMode.Direct;
            settings.ConnectTimeout = new TimeSpan(0, 0, 180);
           settings.Server = new MongoServerAddress(serverIP, 27017);

           settings.WaitQueueTimeout = new TimeSpan(0, 0, 180);
           settings.MinConnectionPoolSize =20;
           settings.MaxConnectionPoolSize =500;
            MongoServer server = new MongoServer(settings);
           
            return server;
        }


Thanks!!

Sarnam


To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/Mgx1CU-dopoJ.

To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.

Robert Stam

unread,
May 1, 2012, 11:00:13 AM5/1/12
to mongod...@googlegroups.com
I don't see anything wrong with the code you posted, but it's not a complete program that I can run. For example, I don't see any code starting up threads and can't see what you do with the return value of ExecuteQuery.

Any chance that you can provide a complete program that displays the issue so that I can run it on my machine?

Have you used a memory profiler to find out which type of objects are using up all the memory?
Reply all
Reply to author
Forward
0 new messages