Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[farmshare-discuss] Matlab imread memory leak while reading JPEG2000 images

Jason Scott Bishop bishopj at stanford.edu
Wed Jul 25 12:12:39 PDT 2012


Hi Pierre, Alex opened discussion with mathworks people on this.  I think you can do a quick workaround in the meantime however:

# get the replacement jar
mkdir ~/matlab
cd ~/matlab
wget http://www.jpedal.org/jai_imageio_idrsolutionsBuild.jar

# you now have two choices for how to use in matlab

# 1. static classpath
cp -p /mnt/glusterfs/software/non-free/MATLAB-R2012a/toolbox/local/classpath.txt ~/matlab
edit classpath.txt and put full path to the jar file on first line


# 2. dynamic classpath
# substitute the full path in place of my home dir
javaaddpath('/afs/ir/users/b/i/bishopj/matlab/jai_imageio_idrsolutionsBuild.jar
')

see: http://www.mathworks.com/help/techdoc/matlab_external/f4863.html#f111424

to test, run this first:

module load MATLAB-R2012a


please note that the ~/matlab directory will be used by all versions of matlab.  this means that if you copy classpath.txt from 2012a matlab, you will want to move it out of the way if you use 2011b.

jason


----- Original Message -----
From: "Alex Chekholko" <chekh at stanford.edu>
To: farmshare-discuss at lists.stanford.edu
Sent: Tuesday, July 24, 2012 11:19:59 PM
Subject: Re: [farmshare-discuss] Matlab imread memory leak while reading JPEG2000 images

Hi,

I can confirm that the memory keeps growing similarly when using MATLAB 
R2012a on FarmShare.

I don't think we're going to do anything about it.

Regards,
Alex

On 7/24/12 5:22 PM, Pierre Martineau wrote:
> It looks like there is a memory leak in the Matlab imread function when reading lossless JPEG2000 files; the problem is easily reproduced by running the test program below on corn with the current Matlab version (Release 2011b).  The loop shows the virtual memory growing; kept unbound, Matlab ends up crashing.  Clearing the memory at each iteration using any flavor of "clear" has no effect.  I believe this problem may be related to an alleged Sun JAI bug reported at http://www.jpedal.org/PDFblog/2011/03/java-jai-image-io-jpeg2000-memory-leak-fix/.
>
> Pierre
>
>
> %grab pid of current MATLAB process to monitor memory consumption
> [~, matlabPid] = unix('pidof MATLAB | grep .$');
> matlabPid = strtrim(matlabPid);
>
> %create large (45M) jpeg2000 file
> img = uint8(rand(5000, 3000, 3)*225);
> tmpName = [tempname '.jp2'];
> imwrite(img, tmpName, 'Mode', 'lossless');
> imgInfo = imfinfo(tmpName);
> disp(imgInfo.FileSize);
>
> %iterate reading the same file and monitor virtual memory size
> jp2 = imformats('jp2');
> for i=1:100
>      feval(jp2.read, tmpName);
>      [~, VmData] = unix(['grep VmData: /proc/' matlabPid '/status | awk ' char(39) '{print $2}' char(39)]);
>      disp(VmData);
> end
>
> %clean up
> delete(tmpName);
>
>
> _______________________________________________
> farmshare-discuss mailing list
> farmshare-discuss at lists.stanford.edu
> https://mailman.stanford.edu/mailman/listinfo/farmshare-discuss
>

-- 
Alex Chekholko chekh at stanford.edu 347-401-4860
_______________________________________________
farmshare-discuss mailing list
farmshare-discuss at lists.stanford.edu
https://mailman.stanford.edu/mailman/listinfo/farmshare-discuss



More information about the farmshare-discuss mailing list