Over a million developers have joined DZone.

PyMongo 2.6.1 Released With Refleak Fix

Easily build powerful user management, authentication, and authorization into your web and mobile applications. Download this Forrester report on the new landscape of Customer Identity and Access Management, brought to you in partnership with Stormpath.

Leak

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 by Stormpath—offering a complete, pre-built User Management API for building web and mobile applications, and APIs. Download our new whitepaper: "Build Versus Buy: Customer Identity Management for Web and Mobile Applications".

Topics:

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 }}