equal
deleted
inserted
replaced
79 // calculate the low-memory threshold below which we fail any attempt to allocate memory |
79 // calculate the low-memory threshold below which we fail any attempt to allocate memory |
80 TMemoryInfoV1Buf meminfo; |
80 TMemoryInfoV1Buf meminfo; |
81 TInt r = UserHal::MemoryInfo(meminfo); |
81 TInt r = UserHal::MemoryInfo(meminfo); |
82 ASSERT(r==KErrNone); |
82 ASSERT(r==KErrNone); |
83 User::LeaveIfError(r); |
83 User::LeaveIfError(r); |
84 iLowMemoryThreshold = (meminfo().iTotalRamInBytes * TGlobalCacheMemorySettings::LowMemoryThreshold()) / 100; |
84 iLowMemoryThreshold = (TInt) (meminfo().iTotalRamInBytes * (TGlobalCacheMemorySettings::LowMemoryThreshold() / 100.00)); |
85 TChunkCreateInfo createInfo; |
85 TChunkCreateInfo createInfo; |
86 createInfo.SetCache(iSizeInBytes); |
86 createInfo.SetCache(iSizeInBytes); |
87 createInfo.SetOwner(EOwnerProcess); |
87 createInfo.SetOwner(EOwnerProcess); |
88 r = iChunk.Create(createInfo); |
88 r = iChunk.Create(createInfo); |
89 ASSERT(r==KErrNone); |
89 ASSERT(r==KErrNone); |
285 /** |
285 /** |
286 Global factory function of CCacheMemoryManager. |
286 Global factory function of CCacheMemoryManager. |
287 */ |
287 */ |
288 void CCacheMemoryManagerFactory::CreateL() |
288 void CCacheMemoryManagerFactory::CreateL() |
289 { |
289 { |
|
290 // Panic in DEBUG mode when GlobalCacheMemorySize is set as a negative value. |
|
291 ASSERT(TGlobalCacheMemorySettings::CacheSize() >= 0); |
|
292 ASSERT(TGlobalCacheMemorySettings::LowMemoryThreshold() >= 0); |
|
293 |
290 if (TGlobalCacheMemorySettings::CacheSize() > 0) |
294 if (TGlobalCacheMemorySettings::CacheSize() > 0) |
291 iCacheMemoryManager = CCacheMemoryManager::NewL(TGlobalCacheMemorySettings::CacheSize()); |
295 iCacheMemoryManager = CCacheMemoryManager::NewL(TGlobalCacheMemorySettings::CacheSize()); |
292 else |
296 else |
293 __PRINT(_L("\"GlobalCacheMemorySize\" set <= 0, CCacheMemoryManager is not created!!!")); |
297 __PRINT(_L("\"GlobalCacheMemorySize\" set <= 0, CCacheMemoryManager is not created!!!")); |
294 } |
298 } |
335 TInt32 lowMemoryThreshold; |
339 TInt32 lowMemoryThreshold; |
336 if (F32Properties::GetInt(KLitSectionNameCacheMemory, _L8("LowMemoryThreshold"), lowMemoryThreshold)) |
340 if (F32Properties::GetInt(KLitSectionNameCacheMemory, _L8("LowMemoryThreshold"), lowMemoryThreshold)) |
337 iLowMemoryThreshold = lowMemoryThreshold; |
341 iLowMemoryThreshold = lowMemoryThreshold; |
338 } |
342 } |
339 |
343 |
340 TInt TGlobalCacheMemorySettings::CacheSize() |
344 TInt32 TGlobalCacheMemorySettings::CacheSize() |
341 { |
345 { |
342 return iCacheSizeInBytes; |
346 return iCacheSizeInBytes; |
343 } |
347 } |
344 |
348 |
345 TInt TGlobalCacheMemorySettings::LowMemoryThreshold() |
349 TInt32 TGlobalCacheMemorySettings::LowMemoryThreshold() |
346 { |
350 { |
347 return iLowMemoryThreshold; |
351 return iLowMemoryThreshold; |
348 } |
352 } |
349 |
353 |
350 |
354 |