Symbian
Symbian OS Library

FAQ-1253 How does setting EPOCHEAPSIZE in the MMP file affect process creation/execution?

[Index][spacer] [Previous] [Next]



 

Classification: C++ Category: Base
Created: 03/30/2005 Modified: 04/25/2005
Number: FAQ-1253
Platform: Not Applicable

Question:
What heap granularity does the EPOCHEAPSIZE offer when used in the mmp file?

Answer:
How does setting EPOCHEAPSIZE in the MMP file affect process creation/execution?
    The EPOCHEAPSIZE directive can be set in the mmp file to reserve or constrict the amount of procurable heap available to the process during start-up and at run-time. See the Symbian Developer Library for more details on the syntax.

    Setting EPOCHEAPSIZE results in the following behaviour:
      • The minimum value ensures that the process does not start/run unless the device has the specified amount of free memory available (for the process). When setting the minimum value the system reserves/commits (not allocate) the required minimum heap for the process during creation. The process is then free to allocate memory from the reserved/committed heap.
      • The maximum value limits the amount of heap the process can consume. Allocating memory beyond this limit results in a KErrNoMemory allocation failure. Setting the maximum limit, however, does not reserve any memory from the phone's memory pool; hence, allocation can fail prior to this limit.

      What heap granularity does the EPOCHEAPSIZE provide when set in the mmp file?

      When setting EPOCHEAPSIZE the system rounds off the size of the (unused) committed heap and allocation boundary to the device's memory page size. Memory allocation is done via the process's default chunk. For example...

      EPOCHEAPSIZE 0x3400 0x3400 // 13 Kb

      will equate to below, if the processor page size is 4096 bytes.

      EPOCHEAPSIZE 0x4000 0x4000 // 16 Kb

      You can get the processor's page size using:

      TInt pagesize=0;
      User::LeaveIfError(HAL::Get(HALData::EMemoryPageSize, pagesize));

      Notes:
        1. The EPOCHEAPSIZE directive applies to the main/primary thread of the process. If other threads in the process use their own heap, the directive plays no part. Secondary threads are affected if they share the main thread's heap.
        2. This directive is ignored in the Emulator on EKA1-based versions of Symbian OS (EKA1 does not support process creation on the Emulator). The EKA2 Emulator obeys the directive for a process.
        3. The minimum and maximum values can be the same. The process will not start if the minimum value cannot be reserved.
        4. Setting EPOCHEAPSIZE for UI applications (.app) pre-v9.x Symbian OS has no affect on the application's heap. Pre-v9.x applications are run in a hosting process (AppRun.exe) which has its own heap limit set to 1 Meg. However, post v9.x Symbian OS UI applications can use this directive to influence heap size.
        5. Using EPOCHEAPSIZE dictates when a process/application can run. Setting the minimum value too high might cause the application not to start in an otherwise memory free phone; hence, observe caution when using EPOCHEAPSIZE. Some uses of EPOCHEAPSIZE are:
            • restricting memory in a test enviroment,
            • to curb (and set a deterministic limit on) memory consumption either due to some requirement or simply as a matter of best practice.