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] [October 2015 Threads] errCOULD_NOT_ALLOCATE_REQUIRED_MEMORYPosted 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_MEMORYPosted 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_MEMORYPosted 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_MEMORYPosted by yukunduan on October 13, 2015
errCOULD_NOT_ALLOCATE_REQUIRED_MEMORYPosted 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).
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|