Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

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.


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner