Detemining total free memory
Article Metadata
Tested with
Devices(s): N78
Compatibility
Platform(s): S60 3rd,3rd FP1, 3rd Fp2
Article
Keywords: TDriveInfo,TDriveInfo::Drive(),TDriveInfo::Volume()
Created: lming
(17 Nov 2008)
Last edited: hamishwillee
(19 Sep 2012)
Contents |
Overview
This snippet can be self-signed. This code snippet demonstrate how to determine total free Memory.
Use case
In some conditions, the application needs to know the amount of free memory available before performing some operation.
Source file
//necessary library
LIBRARY efsrv.lib
//necessary header file
#include <f32file.h>
RFs fileSession;
TVolumeInfo volumeInfo;
//open RFs session
fileSession.Connect();
//freeMemory will store number of free memory in Bytes
TBuf<64> freeMemory;
TInt64 freeKBytes;
//Contains drive information.
TDriveInfo driveInfo;
//check all drives from A to Z
for (TInt driveNumber=EDriveA; driveNumber<=EDriveZ; driveNumber++)
{
//Gets information of this drive
fileSession.Drive(driveInfo,driveNumber);
//if this drive is EMediaRam,we find drive of RAM
if(driveInfo.iType == EMediaRam)
{
//finding drive of memory, recode its free memory in bytes
fileSession.Volume(volumeInfo,driveNumber);
freeKBytes = volumeInfo.iFree/1024;
freeMemory.Num(freeKBytes);
break;
}
}
....
//close RFs session
fileSession.Close();
Postconditions
the freeMemory variable contains the amount of free memory in bytes.


Please specify the devices tested with this code snippet.
-- Wiki administration team.