Quality RTOS & Embedded Software

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


Loading

errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY

Posted by yukunduan on October 13, 2015

When I created a task,the task created and run success.Then It,s delete itself. But when i created it again,the xTaskCreate function return errCOULDNOTALLOCATEREQUIREDMEMORY. So ,I think the problem is that I delete the function without free memory. So,How to free the "usStackDepth" memory ? And i see the task vTaskDelete description:The idle task is responsible for freeing the RTOS kernel allocated memory from tasks that have been deleted. So it means the idle task not be executed in my project?


errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY

Posted by richard_damon on October 13, 2015

That is possible, do you have some task that doesn't block, but sits in a polling loop? That will keep the idle task from running as you never give it a chance. (Note, calling taskYield() will NOT let a lower priority task run, only tasks of the same priority, this is a common misconception).

It is also possible that your heap has gotten fragmented by other allocations, blocking the new allocation from succeeding.

I rarely delete tasks, if I am going to need them again, I have them do their work, and then wait on something (queue/semaphore) to tell them to do their work again, as it can be difficult to code in the chances of tasks not being able to be created due to heap exhaustion/fragmentation (I normally try to have NO usage of the heap once the system is up and operational).


errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY

Posted by yukunduan on October 13, 2015

Thanks for your answer. I have solved the problem. 1.add micro blow in FreeRTOSConfig.h define #define INCLUDE_xTaskGetIdleTaskHandle 1 2.Because one task never be in wait except high task run.So the idle task never run.so i add taskDelay function in it. It,s indeed to free memory by calling idle task. Oh, I quite agree with your point about the task deleting.I will consider to change my code.Thank you.


errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY

Posted by yukunduan on October 13, 2015

errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY

Posted by richard_damon on October 13, 2015

Your 1. isn't needed, it enables the creationg of a function xTaskGetIdleTaskHandle() to get the handle used for the IdelTask (perhaps to get run-time stats on it).

My general rule is any task that doesn't naturally have a block for something, (and thus will try to run continiously) should be at the Idle priority (0), and thus will share time with the Idle task. These sort of tasks are generally fairly rare, and are mostly background cleanup tasks (Like Idle is for FreeRTOS).


[ 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