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

# 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


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.


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


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.


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
> 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(, 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

Alex Chekholko chekh at 347-401-4860
farmshare-discuss mailing list
farmshare-discuss at

More information about the farmshare-discuss mailing list