FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [January 2009 Threads] Create a task uses how much heap?Posted by Bonanza35 on January 8, 2009 Where can I find out how much heap is used in creating a task, and what things affect the amount of heap used? I know it's going to be different for different platforms. I'm using an ARM7 and it seems like the minimum is 404 bytes, often 532 or 660 bytes, and one of my tasks uses 812 bytes off the heap on creation. Do these all look reasonable, and why the differences?
RE: Create a task uses how much heap?Posted by Dave on January 8, 2009 Ram used = sizeof( tskTCB ) + ( usStackSize * sizeof( portSTACK_TYPE ) )
usStackSize is the parameter passed to xTaskCreate(). portSTACK_TYPE is unsigned long on an ARM7.
There may also be a couple of extra bytes to ensure the correct alignment.
RE: Create a task uses how much heap?Posted by Bonanza35 on January 8, 2009 >>> Ram used = sizeof( tskTCB ) + ( usStackSize * sizeof( portSTACK_TYPE ) )
Good afternoon, Dave.
How much of that comes from the heap? I assume (usStackSize * sizeof(portSTACK_TYPE)) goes in the stack area, right?
Heap usage for tasks startups for three representative tasks are 404, 532, and 660 bytes. Stack allocations are 64, 96, and 128 respectively. Per the formula above, then, the RAM usage should be 396, 524, and 652 respectively. Each calculated value is 8 bytes below the actual value, so I assume the extra 8 bytes are overhead plus alignment.
It does look like each task is taking heap memory for its stack. Project configuration for the IAR compiler has a STACKS segment (576 bytes) and a HEAP segment (10752 bytes). If the tasks build their stacks on the heap, what is the STACKS segment for?
RE: Create a task uses how much heap?Posted by Dave on January 9, 2009 >How much of that comes from the heap? I assume (usStackSize >* sizeof(portSTACK_TYPE)) goes in the stack area, right?
The memory is used as the stack for the task but comes from the FreeRTOS heap - heap_1, heap_2, heap_3, or whatever you have used.
The stack segment is used for main() before the kernel starts but can be used for whatever you like after that. You can use it for the IRQ stack to avoid allocating memory for both.
The heap segment setup by the compiler is only used if you are using heap_3 or calling malloc() directory (instead of pvPortMalloc). If you are not doing either of these then set it to its minimum value, probably 4.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|