RNA-FRETools / MASH-FRET

MATLAB package to analyze single-molecule FRET data
https://rna-fretools.github.io/MASH-FRET/
GNU General Public License v3.0
8 stars 2 forks source link

Incorrect checking of available memory on MacOS #94

Closed AndersBarth closed 1 year ago

AndersBarth commented 1 year ago

Hi Richard and Melodie,

Thanks for providing this amazing piece of software! I started using MASH-FRET on MacOS and found a small bug related to querying the available memory (see below).

Describe the bug The memory check upon loading TIF files does not work correctly on MacOS.

To Reproduce Load TIF file of smaller size than available memory. MASH-FRET displays error that memory is insufficient.

Solution Can be fixed by minor modification to memAlloc.m by distinguishing between MacOS and Linux-based systems, as follows:

function ok = memAlloc(arr_size)
ok = 1;
if ~contains(computer,'PCWIN') % not Windows platfroms
    if ismac % MACOS
        [~, w] = system('sysctl hw.memsize | awk ''{print $2}''');
        maxsz = str2double(w);
    else % LINUX
        % from angainor (https://stackoverflow.com/questions/12350598/how-to-access-memory-information-in-matlab-on-unix-equivalent-of-user-view-max)
        [~,w] = unix('free -b | grep Mem');
        stats = str2double(regexp(w, '[0-9]*', 'match'));
        maxsz = stats(end);
    end
else
    mem = memory;
    maxsz = mem.MaxPossibleArrayBytes;
end

if arr_size>=maxsz
    ok = 0;
    return
end
mca-sh commented 1 year ago

Hi Anders,

Thank you for the feedback (and the fix!!) The master branch will be corrected accordingly.

I wish you fun with the software ^^ Mélodie