void FragmentMemoryFunc() { ChunkCommitEnd = 0; TInt r; while(KErrNone == (r = Chunk.Commit(ChunkCommitEnd,PageSize)) && !FragThreadStop) { ChunkCommitEnd += PageSize; } if (FragThreadStop) return; test_Equal(KErrNoMemory, r); TUint freeBlocks = 0; for ( TUint offset = 0; (offset + FragData.iSize) < ChunkCommitEnd; offset += FragData.iFrequency, freeBlocks++) { test_KErrNone(Chunk.Decommit(offset, FragData.iSize)); } if (FragData.iDiscard && CacheSizeAdjustable && !FragThreadStop) { TUint minCacheSize = FreeRam(); TUint maxCacheSize = minCacheSize; DPTest::SetCacheSize(minCacheSize, maxCacheSize); if (OrigMinCacheSize <= maxCacheSize) DPTest::SetCacheSize(OrigMinCacheSize, maxCacheSize); } }
// Only commits and decommits the first page as that is the only page that is being moved. // Plus this ensures the page table and page directories of the chunk are always allocated // and therefore prevents Epoc::LinearToPhysical() from crashing the system. TInt CommitDecommit(TAny* aParam) { RChunk* chunk = (RChunk*) aParam; volatile TUint8* byte = chunk->Base(); FOREVER { *byte = *byte; User::AfterHighRes(0); TInt r = chunk->Decommit(0, PageSize); if (r != KErrNone) return r; User::AfterHighRes(0); r = chunk->Commit(0, PageSize); if (r != KErrNone) return r; } }
void UnfragmentMemoryFunc() { if (FragData.iDiscard && CacheSizeAdjustable) DPTest::SetCacheSize(OrigMinCacheSize, OrigMaxCacheSize); Chunk.Decommit(0, Chunk.MaxSize()); }