EditObjectsManually memory leak

I noticed that when I’m using CellProfiler (v.9978) (on Windows 7 32-bit) to examine a batch of images, the RAM usage quickly climbs to nearly a gigabyte and I start getting MemoryErrors. So I started to look into it, and it appears there is a memory leak in one of the modules.

I have a pipeline that performs multiple image manipulations, IdentifyPrimaryObjects, and EditObjectsManually for one or more images with all “visible” flags set to false.

CellProfiler starts up at ~75 MB. If I run my pipeline on one 1024x1024x12-bit image, without displaying anything, I’m left with 120 MB. If I display an image, 125 MB when the image is closed and multiple runs don’t accumulate memory. If I display an IdentifyPrimaryObjects module, it’s 165 MB when the result image is closed, which also doesn’t seem to accumulate between runs.

However, if I display EditObjectsManually, even without removing any objects, once the run ends I’m left with 250 MB when I close the EditObjectsManually result window. If I run the pipeline again on the same image, 372 MB when the result window is closed. A third time, 495 MB. So every time the EditObjectsManually window is displayed, ~125 MB is consumed and never released, and is thus the source of my MemoryError issues. ConserveMemory doesn’t help, of course, since that is geared toward releasing images purposely maintained outside of the module.

I don’t really know enough about Python to contribute to fixing the bug; my programing experience is limited to Visual Basic .Net. However, I very much need this module to work for my analysis and as I’m typically analyzing ~70 images for a single experiment, I don’t have a spare 10 GB of RAM lying around that might allow me to use it (assuming CellProfiler could even access that much RAM), so if someone might be able to point me in the right direction I could at least take a look.

Thanks for reporting this. We’ve found the problem; we had a systematic error in our interactive modules that caused them to retain the displays that are used when editing. The displays hold on to the images and the image memory is never released.

We’re in the process of releasing an update for CellProfiler 2.0 and there are preliminary builds of good quality for the Windows platform (both 32 & 64-bit). I’ve patched the release with Thouis Jones’ fix for your problem and put the binaries on my personal website: http://www.broadinstitute.org/~leek. We have to run through some installation and UI checks on this latest patched build before releasing, but I’d invite you to try it out and see if it solves your memory problem.


The fixed build is working fine. Thanks!

Edit: Although I should add that in this build the cursor in the image window for zooming is black, and since my images are mostly black, I can’t see where I’m pointing anymore.

Thanks, we are aware of the annoying-crosshair issue; see this post: