{{ !articles[0].partner.isSponsoringArticle ? "Platinum" : "Portal" }} Partner

PyMongo 2.6.1 Released With Refleak Fix


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.

Published at DZone with permission of {{ articles[0].authors[0].realName }}, DZone MVB. (source)

Opinions expressed by DZone contributors are their own.

{{ tag }}, {{tag}},

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

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks