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] [August 2009 Threads] Memory Leak ?!Posted by diodedan on August 1, 2009 Hi all,
I am using an Atmel atmega 128 running at 16 MHz. The settings are as follows:
#define configUSE_PREEMPTION1 #define configUSE_IDLE_HOOK0 #define configUSE_TICK_HOOK0 #define configCPU_CLOCK_HZ( ( unsigned portLONG ) 16000000 ) #define configTICK_RATE_HZ( ( portTickType ) 500 ) #define configMAX_PRIORITIES( ( unsigned portBASE_TYPE ) 3 ) #define configMINIMAL_STACK_SIZE( ( unsigned portSHORT ) 85 ) #define configTOTAL_HEAP_SIZE( (size_t ) ( 2000 ) )//Atmega 128 has 4kbyte of SRAM (about half now) #define configMAX_TASK_NAME_LEN( 8 ) #define configUSE_TRACE_FACILITY0 #define configUSE_16_BIT_TICKS1 #define configIDLE_SHOULD_YIELD1 #define configQUEUE_REGISTRY_SIZE0
I've been able to get three tasks to work. However, this crazy problem happens where after some time, two of the tasks fail, but the third task continues to operate. This problem seems indicative of a memory leak!
My question becomes: how does one prevent this leak? I've been using static variables in my local functions. Also, the tasks call other functions. Could the stack overflow from this?
Any hints/personal experiences?
Thanks much, diodedan
RE: Memory Leak ?!Posted by diodedan on August 1, 2009 I guess my major questions are: 1) How do "static" variables in local functions interact with FreeRTOS and its memory scheme? 2) Why do two tasks that normally work fine alone fail when they are running together (and after some time, approx 6-10 mins) 3) How can I debug this?
RE: Memory Leak ?!Posted by MEdwards on August 1, 2009 What makes you think it is a memory leak? FreeRTOS only allocates memory when a task or queue is created, so a memory leak would seem doubtful.
Are you tasks using dynamic memory allocation? If so then they may be leaking memory or suffering fragmentation issues.
You can check for stack overflows http://www.freertos.org/Stacks-and-stack-overflow-checking.html and http://www.freertos.org/uxTaskGetStackHighWaterMark.html
RE: Memory Leak ?!Posted by SPaik on August 3, 2009 Don't forget that malloc() may not be thread safe. If you are using your system's malloc() inside of tasks, you might want to wrap it inside of something like a semaphore to protect it.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|