Skip to content

Commit

Permalink
SERVER-3102: clear JS contexts in case of OOM
Browse files Browse the repository at this point in the history
  • Loading branch information
agirbal committed Sep 26, 2011
1 parent b866ce0 commit 7fcb737
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions scripting/engine.cpp
Expand Up @@ -284,14 +284,23 @@ namespace mongo {
void done( const string& pool , Scope * s ) {
scoped_lock lk( _mutex );
list<Scope*> & l = _pools[pool];
// make we dont keep to many contexts, or use them for too long
if ( l.size() > 10 || s->getTimeUsed() > 100 ) {
string err = s->getError();
bool oom = (err.find("out of memory") != string::npos);

// do not keep too many contexts, or use them for too long
if ( l.size() > 10 || s->getTimeUsed() > 100 || oom ) {
delete s;
}
else {
l.push_back( s );
s->reset();
}

if (oom) {
// out of mem, make some room
log() << "Clearing all idle JS contexts due to out of memory" << endl;
clear();
}
}

Scope * get( const string& pool ) {
Expand Down

0 comments on commit 7fcb737

Please sign in to comment.