equal
deleted
inserted
replaced
16 // |
16 // |
17 |
17 |
18 #ifndef __FREERAM_H__ |
18 #ifndef __FREERAM_H__ |
19 #define __FREERAM_H__ |
19 #define __FREERAM_H__ |
20 |
20 |
21 /** |
21 // |
22 Get the amount of free RAM in the system in bytes. |
22 // returns the free RAM in bytes |
23 |
23 // |
24 This calls the kernel HAL supervisor barrier to ensure that asynchronous cleanup in the supervisor |
24 inline TInt FreeRam() |
25 happens before the amount of free RAM is measured. |
|
26 |
|
27 There is also the option to wait for upto a specified timeout for the system to become idle. |
|
28 |
|
29 @param aIdleTimeoutMs If non-zero, the number of milliseconds to wait for the system to become idle. |
|
30 |
|
31 @return On sucess returns the amount of free RAM in bytes, KErrTimedOut if the timeout expired |
|
32 without the system becoming idle, or one of the other system-wide error codes. |
|
33 */ |
|
34 TInt FreeRam(TInt aIdleTimeoutMs = 0) |
|
35 { |
25 { |
36 // wait for any async cleanup in the supervisor to finish first... |
26 // wait for any async cleanup in the supervisor to finish first... |
37 TInt r = UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, |
27 UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, 0, 0); |
38 (TAny*)aIdleTimeoutMs, 0); |
|
39 if (r != KErrNone) |
|
40 return r; |
|
41 |
28 |
42 TMemoryInfoV1Buf meminfo; |
29 TMemoryInfoV1Buf meminfo; |
43 r = UserHal::MemoryInfo(meminfo); |
30 UserHal::MemoryInfo(meminfo); |
44 if (r != KErrNone) |
|
45 return r; |
|
46 |
|
47 return meminfo().iFreeRamInBytes; |
31 return meminfo().iFreeRamInBytes; |
48 } |
32 } |
49 |
33 |
50 #endif |
34 #endif |