diff -r c734af59ce98 -r 5b5d147c7838 kernel/eka/memmodel/epoc/flexible/mmu/mmu.cpp --- a/kernel/eka/memmodel/epoc/flexible/mmu/mmu.cpp Tue May 11 17:28:22 2010 +0300 +++ b/kernel/eka/memmodel/epoc/flexible/mmu/mmu.cpp Tue May 25 14:09:55 2010 +0300 @@ -859,8 +859,14 @@ } #endif TInt missing = iRamPageAllocator->AllocRamPages(aPages, aCount, aZonePageType, aBlockZoneId, aBlockRest); - if(missing && !(aFlags&EAllocNoPagerReclaim) && ThePager.GetFreePages(missing)) - missing = iRamPageAllocator->AllocRamPages(aPages, aCount, aZonePageType, aBlockZoneId, aBlockRest); + if(missing && !(aFlags&EAllocNoPagerReclaim)) + { + // taking the page cleaning lock here prevents the pager releasing the ram alloc lock + PageCleaningLock::Lock(); + if (ThePager.GetFreePages(missing)) + missing = iRamPageAllocator->AllocRamPages(aPages, aCount, aZonePageType, aBlockZoneId, aBlockRest); + PageCleaningLock::Unlock(); + } TInt r = missing ? KErrNoMemory : KErrNone; if(r!=KErrNone) iRamAllocFailed = ETrue;