×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    217

    Code for test MEM-01

    Hi,

    I would like to know how I can check the memory at startup to pass the mem-01 test. I have seen some parameters in the carbide, opening the mmp file (Minimum heap size, Maximum heap size, Stack size), and I don't know if I should use these parameters to pass this test.

    Thanks in advance,
    Benji.

  2. #2
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    217

    Re: Code for test MEM-01

    I have seen that I can use this code to check it:

    Free RAM:
    TInt freeRam = 0;
    HAL::Get( HAL::EMemoryRAMFree, freeRam );

    Thread`s heap memory:
    User::Available();

    but what can be considered low memory? which free memory: RAM, thread`s heap?

    BR,
    Benji.

  3. #3
    Regular Contributor
    Join Date
    Mar 2006
    Posts
    280

    Re: Code for test MEM-01

    Hi;
    The easy way:
    You can use User::Heap().AllocSize(); when your app has initialized fully to see how much memory you have used. Once you know, you can try to allocate this amount of memory right at the start of your app and then free it again. If this allocation works, you can be fairly hopeful the rest of you initialization will complete without running out of memory. (Or you could use User::Available(), not tried it.)

    The hard/proper way:
    Make sure you handle every out of memory in an elegant way.

    MEM-01 is about how you handle out of memory errors. Basically, the test goes like this: it lets your app run multiple times, each time failing a different allocation. So it gives your opportunity fail at almost every place. If it leaves/panics with a memory error too often, it fails.

    Yes, we are talking about the heap.

  4. #4
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    217

    Re: Code for test MEM-01

    Quote Originally Posted by nigel.brown View Post
    Hi;
    The easy way:
    You can use User::Heap().AllocSize(); when your app has initialized fully to see how much memory you have used. Once you know, you can try to allocate this amount of memory right at the start of your app and then free it again. If this allocation works, you can be fairly hopeful the rest of you initialization will complete without running out of memory. (Or you could use User::Available(), not tried it.)

    The hard/proper way:
    Make sure you handle every out of memory in an elegant way.

    MEM-01 is about how you handle out of memory errors. Basically, the test goes like this: it lets your app run multiple times, each time failing a different allocation. So it gives your opportunity fail at almost every place. If it leaves/panics with a memory error too often, it fails.

    Yes, we are talking about the heap.
    So, I have to assure that my application will be able to alloc enough memory, regardless of the performance of the OS. Because the free ram will affect to this performance. And, of course, I have to manage correctly all KErrNoMemory leaves.

    Thanks Nigel.

Similar Threads

  1. Replies: 2
    Last Post: 2007-10-05, 20:40
  2. outOfMemory exception on device with 2mb memory
    By gx in forum Mobile Java General
    Replies: 6
    Last Post: 2007-05-24, 10:33
  3. stupid error!
    By bojkar in forum Symbian
    Replies: 1
    Last Post: 2006-12-14, 05:47
  4. Link errors when trying to Display bitmap
    By Bkc82 in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2006-01-16, 22:46
  5. Replies: 0
    Last Post: 2003-09-26, 15:07

Posting Permissions

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