Over a million developers have joined DZone.
Platinum Partner

PyMongo 2.6.1 Released With Refleak Fix

The Web Dev Zone is brought to you in partnership with Mendix.  Discover how IT departments looking for ways to keep up with demand for business apps has caused a new breed of developers to surface - the Rapid Application Developer.


Bernie Hackett and I released PyMongo 2.6.1 yesterday. This version fixes a bug in PyMongo 2.6, a reference-count leak in insert() that caused memory to grow slowly without bound. Please upgrade immediately.

Sorry about the bug. We introduced it into PyMongo's C code while implementing auto-splitting for very large batch inserts, but it affects all calls to insert regardless of size. If you use PyMongo without building its C extensions, for example if you're on PyPy or Jython, the bug does not affect you.

The new auto-splitting code serializes a sequence of documents as BSON until its buffer reaches 48MB, at which point it calls, from C, the Python method _send_message to fire off the batch to the server. Unfortunately, the C code didn't dereference the server response from _send_message. The response is small, something like this:

{'ok': 1.0, 'err': None, 'n': 0, 'connectionId': 123}

Each response was leaked, and the memory added up fast if you called insert in a tight loop. The fix is simply to decref the response.

The Web Dev Zone is brought to you in partnership with Mendix.  Learn more about The Essentials of Digital Innovation and how it needs to be at the heart of every organization.


Published at DZone with permission of A. Jesse Jiryu Davis , DZone MVB .

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}