webengine/osswebengine/MemoryManager/Src/MemoryPool.cpp
changeset 16 a359256acfc6
parent 8 7c90e6132015
child 37 cb62a4f66ebe
equal deleted inserted replaced
13:10e98eab6f85 16:a359256acfc6
   618 						// Not fatal anyway because all the handles are process local and we should only
   618 						// Not fatal anyway because all the handles are process local and we should only
   619 						// be deleting this object when we're closing the allocator - which we never do
   619 						// be deleting this object when we're closing the allocator - which we never do
   620 						// except at process end.
   620 						// except at process end.
   621 	}
   621 	}
   622 
   622 
   623 const TInt KMaxHeapSize = 0x2000000; //32MB
   623 #ifdef __WINSCW__
   624 const TInt KHeapGrowSize = 0x10000;  //64KB
   624 const TInt KMaxHeapSize = 0x2000000; // 32MB, on emulator
       
   625 #else
       
   626 const TInt KMaxHeapSize = 0x4000000; // 64MB, on hardware
       
   627 #endif
       
   628 
       
   629 const TInt KHeapGrowSize = 0x10000;  // 64KB
   625 
   630 
   626 TBool CNewSymbianHeapPool::Create()
   631 TBool CNewSymbianHeapPool::Create()
   627 	{
   632 	{
   628 	// need to know system page size
   633 	// need to know system page size
   629 	TInt page_size;
   634 	TInt page_size;
   630 	UserHal::PageSizeInBytes(page_size);
   635 	UserHal::PageSizeInBytes(page_size);
   631 
   636 	
   632 	// Create the thread's heap chunk.
   637     TInt maxmem = 0;
   633 	//
   638     HAL::Get(HALData::EMemoryRAM, maxmem);
   634 	// The chunk needs reserve enough address space for twice the maximum allocation
   639     TInt maxHeapSize = Min(maxmem, KMaxHeapSize);
   635 	// The heap object is instantiated exactly half way up the chunk, and initially is provided just 1 page of memory
   640         
   636 	// This memory can be committed as part of the call to creat the chunk
   641 	/* Create the thread's heap chunk.
   637 	//
   642 	 * The chunk needs reserve enough address space for twice the maximum allocation
   638 	TInt maxChunkSize = 2 * KMaxHeapSize;
   643 	 * The heap object is instantiated exactly half way up the chunk, and initially is provided just 1 page of memory
   639 	TInt offset = KMaxHeapSize;
   644 	 * This memory can be committed as part of the call to creat the chunk
       
   645 	 */
       
   646 	TInt maxChunkSize = 2 * maxHeapSize;
       
   647 	TInt offset = maxHeapSize;
   640 	TInt minLength = page_size;
   648 	TInt minLength = page_size;
   641 	RChunk c;
   649 	RChunk c;
   642 	TInt r = c.CreateDisconnectedLocal(offset, offset+minLength, maxChunkSize, EOwnerProcess);
   650 	TInt r = c.CreateDisconnectedLocal(offset, offset+minLength, maxChunkSize, EOwnerProcess);
   643 	if (r!=KErrNone)
   651 	if (r!=KErrNone)
   644 		return EFalse;
   652 		return EFalse;
   645 	
   653 	
   646 	iAlloc = new (c.Base() + offset) RSymbianDLHeap(c.Handle(), offset, minLength, KMaxHeapSize, KHeapGrowSize, 8, EFalse /* not single threaded! */);
   654 	iAlloc = new (c.Base() + offset) RSymbianDLHeap(c.Handle(), offset, minLength, maxHeapSize, KHeapGrowSize, 8, EFalse /* not single threaded! */);
   647 	iAlloc->iHandles = &iAlloc->iChunkHandle;
   655 	iAlloc->iHandles = &iAlloc->iChunkHandle;
   648 	iAlloc->iHandleCount = 2;
   656 	iAlloc->iHandleCount = 2;
   649 	// chunk handle now 'owned' by iAlloc
   657 	// chunk handle now 'owned' by iAlloc
   650 	r = iAlloc->iLock.CreateLocal(EOwnerProcess);
   658 	r = iAlloc->iLock.CreateLocal(EOwnerProcess);
   651 
   659 
   653 		return EFalse;
   661 		return EFalse;
   654 	
   662 	
   655 	return CMemoryPool::Create();
   663 	return CMemoryPool::Create();
   656 	}
   664 	}
   657 
   665 
       
   666 #ifdef OOM_LOGGING   
       
   667 void CNewSymbianHeapPool::DumpHeapLogs()
       
   668     {
       
   669     iAlloc->dump_heap_logs(0);
       
   670     iAlloc->dump_dl_free_chunks();
       
   671     }
       
   672 #endif
   658 #endif
   673 #endif
   659 // END OF FILE
   674 // END OF FILE