<html>
    <head>
      <base href="http://fiji.sc/bugzilla/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEEDSINFO "
   title="NEEDSINFO - memory leak with python script"
   href="http://fiji.sc/bugzilla/show_bug.cgi?id=1203#c3">Comment # 3</a>
              on <a class="bz_bug_link 
          bz_status_NEEDSINFO "
   title="NEEDSINFO - memory leak with python script"
   href="http://fiji.sc/bugzilla/show_bug.cgi?id=1203">bug 1203</a>
              from <span class="vcard"><a class="email" href="mailto:aryeh@cc.huji.ac.il" title="Aryeh Weiss <aryeh@cc.huji.ac.il>"> <span class="fn">Aryeh Weiss</span></a>
</span></b>
        <pre>Concerning the python.jar:
This was added whenI needed to evaluate a python script from a plugin - 
    eval("python", script);
When I did this, it prompted me that I to install Jython.jar, and it even was
kind enough to do it for me.

Motivated by Mark's comment, I renamed that jython to python.old, and copied
the Jython snapshot file (which was in jars) to the plugin/jars directory (and
renamed that one to jython.jar). The results are the same for my minimal script

I modified my minimal script to run the gc, and then close the image and runthe
gc again (twice). 

So here is the new script:
from ij import IJ, Prefs, ImagePlus
from ij.io import DirectoryChooser,  OpenDialog
from ij.process import ImageConverter, ByteProcessor, BinaryProcessor
import time, gc

def forceGc():
    print "memory before gc = ", IJ.currentMemory()
    gc.collect()
    print "memory after gc = ", IJ.currentMemory()


op = OpenDialog("Choose input image...", "")
path = op.getDirectory()+ op.getFileName()
inputName = op.getFileName()
inputDir = op.getDirectory()
inputPath = inputDir + inputName

if inputName[-4] == ".":
    inputPrefix = inputName[:-4]    # assumes that a suffix exists
else:
    inputPrefix = inputName


inputImp = ImagePlus(inputPath)
inputImp.show()
ImageConverter(inputImp).convertToGray8()

# The following line makes all the difference.
inputIp = inputImp.getProcessor()
forceGc()

inputImp.close()
forceGc()
forceGc()


and here is the output with an image of about 1 GB:

Started minimal.py at Wed Dec 09 07:06:54 IST 2015
memory before gc =  1037433016L
memory after gc =  1042983208L
memory before gc =  1058432336L
memory after gc =  1044836632L
memory before gc =  1044836632L
memory after gc =  1041655776L

## end offers run on "fresh" Fiji 

Started minimal.py at Wed Dec 09 07:07:12 IST 2015
memory before gc =  2055344376L
memory after gc =  1044025032L
memory before gc =  1056477256L
memory after gc =  1042805472L
memory before gc =  1042971816L
memory after gc =  1036835368L

## end of second run -- nothing open

Wayne -- can you run this script and post the result?</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>