Namespaces
Variants
Actions

Detemining total free memory

Jump to: navigation, search
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.

This page was last modified on 19 September 2012, at 03:34.
463 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved