refs #1252 fix mongo memory leak and double free