×

Discussion Board

Results 1 to 13 of 13
  1. #1
    Registered User
    Join Date
    May 2007
    Posts
    22

    Why Big chunk Malloc Failure in Symbian?

    I have observed Symbian Heap allocator failing when application trying to allocate big chunk of memory ( 4K, 8K, 10 etc). I cross-checked total system memory avilability and found memory more than 3.7 MB RAM is free in the device (when malloc failure happens).

    I have following instuction in mmp file for customize Heap size
    EPOCHEAPSIZE 1048576 2097152

    I am unable to find an API to check memory usage for the applicaton ( or current process). Does Symbian supports any such API?

    Googleing this issue further, I found Symbian Heap allocator may be using an inefficient heap allocator algorithm ( ftp://bells.cs.ucl.ac.uk/functional/...roject.pdf.gz).

    This article has an interesting finding, Symbian heap allocator has 65% internal fragmentation. But this is an old story, must be resolved in Symbian 3rd edition. ( I am using a 3rd edition device (N91) for my testing).

    Do anybody face(ing) such issues with Symbian 3rd Edition phones? What is the appropriate method to avoid such memory failures. Please avoid suggestions like static memory. For example SIP stacks like osip, will do extensive dynamic allocation. This is an appropriate design and Symbian does not de-motivate the usage of Heap.

  2. #2
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Why Big chunk Malloc Failure in Symbian?


  3. #3
    Super Contributor
    Join Date
    Oct 2005
    Location
    Hyderabad,India
    Posts
    1,156

    Re: Why Big chunk Malloc Failure in Symbian?

    Quote Originally Posted by a_binogeorge
    I
    I am unable to find an API to check memory usage for the applicaton ( or current process). Does Symbian supports any such API?
    Try this out.It gives you the amount of Free memory in your RAM.
    Code:
       TInt uid1; 
       HAL::Get(HAL::EMemoryRAMFree, uid1);		   
       TBuf<10>aa;
       aa.Num(uid1);
       User::InfoPrint(aa);
    You need to include hal.h and link to hal.lib

    Priju

  4. #4
    Registered User
    Join Date
    May 2007
    Posts
    22

    Re: Why Big chunk Malloc Failure in Symbian?

    My requirement is to get an ApI, which gives, Total Heap memory used by current process or a particular application.

  5. #5
    Super Contributor
    Join Date
    Oct 2005
    Location
    Hyderabad,India
    Posts
    1,156

    Re: Why Big chunk Malloc Failure in Symbian?

    May be you could try Memory Monitor Application in preversion 9 devices and you could search for RHeap in the sdk help.Its got the related API's that you are looking for.
    Last edited by Priju Jacob Paul; 2007-05-10 at 06:10.

  6. #6
    Registered User
    Join Date
    May 2007
    Posts
    22

    Re: Why Big chunk Malloc Failure in Symbian?

    It seems DevMan is not helpful for 3rd edition phones like N91, N93 etc. Also people doubts about this utility, Please see following comments.

    > Memory Monitor
    On January 21st, 2004 mayhem (not verified) said:
    I doubt it too. Can the developer show us code how the application get heap usage?

    > Memory Monitor
    On January 29th, 2004 mayhem (not verified) said:
    hmm.. now I get it. it doesn't show heap usage. it shows heap size...



    Also we are deviating from the topic. My requirement is to understand, why Symbian Heap Allocator returns NULL, when I try to allocate big memory chunk?

  7. #7
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: Why Big chunk Malloc Failure in Symbian?

    It will return null when it runs out of memory. What is the size of the block you are trying to allocate when it fails?

    Try calling User::CompressAllHeaps() before attempting to allocate all the memory.

    You can use User::Allocator() or User::Heap() to get the current heap class to see how much you have allocatred, number of cells etc.

    How may allocations are you doing and what size?

  8. #8
    Registered User
    Join Date
    May 2007
    Posts
    22

    Re: Why Big chunk Malloc Failure in Symbian?

    This is one of the limitation of Symbian Heap Allocator. RHeap provides an API(Size()) to get heap Size. Description as follows

    Gets the current size of the heap.
    This is the total number of bytes committed by the host chunk.
    Note that this value is always greater than the total space available across all allocated cells.


    I am not able to find any API, which provides currently used heap or free heap.

    Heap Comopress is no more supported in Symbian 3rd Edition. See excerpts from Symbian Internals section 7.5.2.3 Allocators in Symbian OS.

    "Compress() Release any unused pages of memory back to the OS, if possible. This function is deprecated, but retained for EKA1 compatibility. Allocators for EKA2 are expected to do this automatically as a side effect of Free() rather than wait for an explicit request".
    ----------------------------
    Bino George
    IM: a_binogeorge@yahoo.com a.binogeorge@gmail.com
    Mobile: +91-98861-74374

  9. #9
    Registered User
    Join Date
    May 2007
    Posts
    22

    Re: Why Big chunk Malloc Failure in Symbian?

    /******** Re pasted from other Thread, which is deprecated */

    Symbian OS Internals ( Section: 7.5.2: Free Store Allocators and Heaps), provides details about Symbian default alloctor (RHeap).

    Default RHeap is defined as 'First fit, Address Ordered, Free List Allocator".

    RHeap Allocation Algorithm
    ---------------------------------------
    "The allocation algorithm searches the free list from the start until a block is found that is large enough to satisfy the request. If the allocator finds such a block, the allocator splits the free block into the requested allocated block and any remaining free space, which is kept on the free list. Sometimes the block is only just large enough for the request (or the remaining space is too small to keep on the free list) in which case the whole block is returned by the request. If there is no free block large enough, the allocator tries to extend the chunk to create a larger free block at the end of the heap to satisfy the request".

    This algorithm looks decent and can not produce any pathological internal fragemenation.

    Can Symbian allocator, when trying to extend the chunk, return a NULL?

    Any input?
    ----------------------------
    Bino George
    IM: a_binogeorge@yahoo.com a.binogeorge@gmail.com
    Mobile: +91-98861-74374

  10. #10
    Registered User
    Join Date
    May 2007
    Posts
    22

    Re: Why Big chunk Malloc Failure in Symbian?

    It seems we have an API (user::CountAllocCells() ) to check current free heap cells. Let me try this.
    ----------------------------
    Bino George
    IM: a_binogeorge@yahoo.com a.binogeorge@gmail.com
    Mobile: +91-98861-74374

  11. #11
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: Why Big chunk Malloc Failure in Symbian?

    You can use RHeap::AllocSize to get the amount allocated and RHeap::Available to get the avaliable memory and the size of the largest free block.

    As I said above, you can use User::Heap() to get the default heap for the process.

    I assume you have read http://www.symbian.com/developer/tec...ent/index.html

  12. #12
    Registered User
    Join Date
    May 2007
    Posts
    22

    Re: Why Big chunk Malloc Failure in Symbian?

    Thanks for everybody's help.

    If anybody need to analyze process heap status, use following routine.

    void GetHeapStatus(void)
    {
    int TotalHeapBytes, TotalHeapCells, UsedHeapCells, FreeHeapCells, FreeBytes, BiggestBlock;

    /* Get Process Heap Status */
    TotalHeapCells = User::AllocSize(TotalHeapBytes);
    UsedHeapCells = User::CountAllocCells(FreeHeapCells);
    FreeBytes = User::Available(BiggestBlock);

    DEBUG_PRINT(("Heap Status: Total Heap Cells:%d Heap Size:%d", TotalHeapCells, TotalHeapBytes));
    DEBUG_PRINT(("Heap Cells Used:%d Free:%d Free Bytes:%d Biggest BlockSize:%d", UsedHeapCells, FreeHeapCells, FreeBytes, BiggestBlock));
    return;
    }
    Last edited by a_binogeorge; 2007-05-11 at 08:16.
    ----------------------------
    Bino George
    IM: a_binogeorge@yahoo.com a.binogeorge@gmail.com
    Mobile: +91-98861-74374

  13. #13
    Registered User
    Join Date
    Jun 2004
    Posts
    25

    Re: Why Big chunk Malloc Failure in Symbian?

    Hi binogeorge,

    I cannot access the paper you mentioned, can you help send me a copy to newcomm@gmail.com ?

    Thanks

Similar Threads

  1. 7650 Symbian Connect
    By alexbas in forum Symbian Tools & SDKs
    Replies: 4
    Last Post: 2008-11-16, 10:40
  2. Symbian C++ or MDIP: some newbie questions
    By sgalmeida in forum Symbian
    Replies: 2
    Last Post: 2006-12-30, 08:57
  3. A little survey regarding Java vs Symbian C++
    By Olnex in forum Mobile Java General
    Replies: 0
    Last Post: 2006-11-01, 09:00
  4. Symbian 6.1 SDK generates Java asserion failure
    By svalexandroff in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2003-10-10, 14:57
  5. Replies: 0
    Last Post: 2003-06-13, 01:09

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×