Home > atmlab > handy > freeRAM.m

freeRAM

PURPOSE ^

% freeRAM

SYNOPSIS ^

function freeMB = freeRAM()

DESCRIPTION ^

% freeRAM
 
 PURPOSE: 
        Checks how much RAM is available on your computer.
 
 OUT:    freeRAM [MB]


 Created by Salomon Eliasson
 $Id: freeRAM.m 8287 2013-03-12 10:24:14Z olemke $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

freeRAM.m

SOURCE CODE ^

0001 function freeMB = freeRAM()
0002 %% freeRAM
0003 %
0004 % PURPOSE:
0005 %        Checks how much RAM is available on your computer.
0006 %
0007 % OUT:    freeRAM [MB]
0008 %
0009 %
0010 % Created by Salomon Eliasson
0011 % $Id: freeRAM.m 8287 2013-03-12 10:24:14Z olemke $
0012 
0013 %find how much RAM is left
0014 if ismac
0015     x=regexp(exec_system_cmd('vm_stat | grep -e free -e inactive | sed s/[^0-9]//g'),'\n','split');
0016     freeMB = (str2double(x{1}{1})+str2double(x{1}{2}))*4096/1024/1024;
0017 elseif isunix
0018     x = regexp(exec_system_cmd('free -m'),'\n','split');%MB
0019     [notUsed,free] = regexp(x{1}{1},'free');
0020     
0021     freeMB = str2double(x{1}{3}(free-5:free));
0022     if strcmp(computer,'GLNX86') %32 Bit only allows for a maximum of 3GB
0023         [notUsed,used] = regexp(x{1}{1},'used');
0024         usedMB = str2double(x{1}{3}(used-5:used));
0025         freeMB = 3000-usedMB; 
0026     end
0027 elseif ispc
0028     error(['atmlab:' mfilename ':Platform'],'Function isn''t setup for pc (windows)')
0029 end

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005