Skip to main content
deleted 2 characters in body; edited title
Source Link
dda
  • 1.6k
  • 1
  • 12
  • 18

how How to clear heap memory in esp32ESP32?

I am using Free RTOS on esp32ESP32 in my program. However However at some point of time when I execute xTaskCreate()xTaskCreate() it returns -1 , whichthe error isbeing could_not_allocate_required_memory. In my program, each time iI pring getFreeHeap()getFreeHeap() it is reduced by 20002,000 approximately and is never cleared or reset, when. When it is not sufficient or below 20002,000 xTaskCreate returns -1.

After reading a lot of forums I could not find a way to clear the memory to create a task, can. Can anyone guide me achievingwith this  ?

code snippet

void createTsk(){
  SerialDebug.print("available Heap size: ");
  SerialDebug.println(ESP.getFreeHeap());

  BaseType_t xBy = xTaskCreate(taskPriorityOne, "TaskOne", 20240, NULL, 1, &thOne);
  SerialDebug.println("Return Val : ");
  SerialDebug.println(xBy);
}

void taskPriorityOne(void *paramter)
{
   SerialDebug.println("Prio 1 task Initiated");
   threadTask(priorityOneQue, "task1", thOne);
}

void threadTask(QueueHandle_t priorityQue, String taskName, TaskHandle_t th)
{
  xQueueReceive(priorityQue, &taskdataholder, portMAX_DELAY);
  ongoingProcess = taskdataholder;
  furtherExecutionHttp(taskdataholder, fnm, taskName, th);
}

void furtherExecutionHttp(DataHolder *taskdataholder, String fnm, String 
taskName, TaskHandle_t th)
{
   String response = httpRequest(taskdataholder->protocol, taskdataholder- 
   >host, taskdataholder->port, taskdataholder->url, taskdataholder->body, 
   fnm);

  delay(10);

  free(taskdataholder);
  SerialDebug.println("Releasing memory..\n");

  vTaskDelete(th);
}

how to clear heap memory in esp32?

I am using Free RTOS on esp32 in my program. However at some point of time when I execute xTaskCreate() it returns -1 , which error is could_not_allocate_required_memory. In my program, each time i pring getFreeHeap() it is reduced by 2000 approximately and is never cleared or reset, when it is not sufficient or below 2000 xTaskCreate returns -1.

After reading a lot of forums I could not find a way to clear the memory to create a task, can anyone guide me achieving this  ?

code snippet

void createTsk(){
  SerialDebug.print("available Heap size: ");
  SerialDebug.println(ESP.getFreeHeap());

  BaseType_t xBy = xTaskCreate(taskPriorityOne, "TaskOne", 20240, NULL, 1, &thOne);
  SerialDebug.println("Return Val : ");
  SerialDebug.println(xBy);
}

void taskPriorityOne(void *paramter)
{
   SerialDebug.println("Prio 1 task Initiated");
   threadTask(priorityOneQue, "task1", thOne);
}

void threadTask(QueueHandle_t priorityQue, String taskName, TaskHandle_t th)
{
  xQueueReceive(priorityQue, &taskdataholder, portMAX_DELAY);
  ongoingProcess = taskdataholder;
  furtherExecutionHttp(taskdataholder, fnm, taskName, th);
}

void furtherExecutionHttp(DataHolder *taskdataholder, String fnm, String 
taskName, TaskHandle_t th)
{
   String response = httpRequest(taskdataholder->protocol, taskdataholder- 
   >host, taskdataholder->port, taskdataholder->url, taskdataholder->body, 
   fnm);

  delay(10);

  free(taskdataholder);
  SerialDebug.println("Releasing memory..\n");

  vTaskDelete(th);
}

How to clear heap memory in ESP32?

I am using Free RTOS on ESP32 in my program. However at some point of time when I execute xTaskCreate() it returns -1 , the error being could_not_allocate_required_memory. In my program, each time I pring getFreeHeap() it is reduced by 2,000 approximately and is never cleared or reset. When it is not sufficient or below 2,000 xTaskCreate returns -1.

After reading a lot of forums I could not find a way to clear the memory to create a task. Can anyone guide me with this?

code snippet

void createTsk(){
  SerialDebug.print("available Heap size: ");
  SerialDebug.println(ESP.getFreeHeap());

  BaseType_t xBy = xTaskCreate(taskPriorityOne, "TaskOne", 20240, NULL, 1, &thOne);
  SerialDebug.println("Return Val : ");
  SerialDebug.println(xBy);
}

void taskPriorityOne(void *paramter)
{
   SerialDebug.println("Prio 1 task Initiated");
   threadTask(priorityOneQue, "task1", thOne);
}

void threadTask(QueueHandle_t priorityQue, String taskName, TaskHandle_t th)
{
  xQueueReceive(priorityQue, &taskdataholder, portMAX_DELAY);
  ongoingProcess = taskdataholder;
  furtherExecutionHttp(taskdataholder, fnm, taskName, th);
}

void furtherExecutionHttp(DataHolder *taskdataholder, String fnm, String 
taskName, TaskHandle_t th)
{
   String response = httpRequest(taskdataholder->protocol, taskdataholder- 
   >host, taskdataholder->port, taskdataholder->url, taskdataholder->body, 
   fnm);

  delay(10);

  free(taskdataholder);
  SerialDebug.println("Releasing memory..\n");

  vTaskDelete(th);
}
Bumped by Community user

I am using Free RTOS on esp32 in my program. However at some point of time when I execute xTaskCreate() it returns -1 , which error is could_not_allocate_required_memory. In my program, each time i pring getFreeHeap() it is reduced by 2000 approximately and is never cleared or reset, when it is not sufficient or below 2000 xTaskCreate returns -1.

After reading a lot of forums I could not find a way to clear the memory to create a task, can anyone guide me achieving this ?

code snippet

void createTsk(){
  SerialDebug.print("available Heap size: ");
  SerialDebug.println(ESP.getFreeHeap());

  BaseType_t xBy = xTaskCreate(taskPriorityOne, "TaskOne", 20240, NULL, 1, &thOne);
  SerialDebug.println("Return Val : ");
  SerialDebug.println(xBy);
}

void taskPriorityOne(void *paramter)
{
   SerialDebug.println("Prio 1 task Initiated");
   threadTask(priorityOneQue, "task1", thOne);
}

void threadTask(QueueHandle_t priorityQue, String taskName, TaskHandle_t th)
{

  xQueueReceive(priorityQue, &taskdataholder, portMAX_DELAY);
  ongoingProcess = taskdataholder;
  furtherExecutionHttp(taskdataholder, fnm, taskName, th);

}

void furtherExecutionHttp(DataHolder *taskdataholder, String fnm, String 
taskName, TaskHandle_t th)
{

   String response = httpRequest(taskdataholder->protocol, taskdataholder- 
   >host, taskdataholder->port, taskdataholder->url, taskdataholder->body, 
   fnm);

  delay(10);

  free(taskdataholder);
  SerialDebug.println("Releasing memory..\n");

  vTaskDelete(th);
}
void createTsk(){
  SerialDebug.print("available Heap size: ");
  SerialDebug.println(ESP.getFreeHeap());

  BaseType_t xBy = xTaskCreate(taskPriorityOne, "TaskOne", 20240, NULL, 1, &thOne);
  SerialDebug.println("Return Val : ");
  SerialDebug.println(xBy);
}

void taskPriorityOne(void *paramter)
{
   SerialDebug.println("Prio 1 task Initiated");
   threadTask(priorityOneQue, "task1", thOne);
}

void threadTask(QueueHandle_t priorityQue, String taskName, TaskHandle_t th)
{
  xQueueReceive(priorityQue, &taskdataholder, portMAX_DELAY);
  ongoingProcess = taskdataholder;
  furtherExecutionHttp(taskdataholder, fnm, taskName, th);
}

void furtherExecutionHttp(DataHolder *taskdataholder, String fnm, String 
taskName, TaskHandle_t th)
{
   String response = httpRequest(taskdataholder->protocol, taskdataholder- 
   >host, taskdataholder->port, taskdataholder->url, taskdataholder->body, 
   fnm);

  delay(10);

  free(taskdataholder);
  SerialDebug.println("Releasing memory..\n");

  vTaskDelete(th);
}

I am using Free RTOS on esp32 in my program. However at some point of time when I execute xTaskCreate() it returns -1 , which error is could_not_allocate_required_memory. In my program, each time i pring getFreeHeap() it is reduced by 2000 approximately and is never cleared or reset, when it is not sufficient or below 2000 xTaskCreate returns -1.

After reading a lot of forums I could not find a way to clear the memory to create a task, can anyone guide me achieving this ?

code snippet

void createTsk(){
  SerialDebug.print("available Heap size: ");
  SerialDebug.println(ESP.getFreeHeap());

  BaseType_t xBy = xTaskCreate(taskPriorityOne, "TaskOne", 20240, NULL, 1, &thOne);
  SerialDebug.println("Return Val : ");
  SerialDebug.println(xBy);
}

void taskPriorityOne(void *paramter)
{
   SerialDebug.println("Prio 1 task Initiated");
   threadTask(priorityOneQue, "task1", thOne);
}

void threadTask(QueueHandle_t priorityQue, String taskName, TaskHandle_t th)
{

  xQueueReceive(priorityQue, &taskdataholder, portMAX_DELAY);
  ongoingProcess = taskdataholder;
  furtherExecutionHttp(taskdataholder, fnm, taskName, th);

}

void furtherExecutionHttp(DataHolder *taskdataholder, String fnm, String 
taskName, TaskHandle_t th)
{

   String response = httpRequest(taskdataholder->protocol, taskdataholder- 
   >host, taskdataholder->port, taskdataholder->url, taskdataholder->body, 
   fnm);

  delay(10);

  free(taskdataholder);
  SerialDebug.println("Releasing memory..\n");

  vTaskDelete(th);
}

I am using Free RTOS on esp32 in my program. However at some point of time when I execute xTaskCreate() it returns -1 , which error is could_not_allocate_required_memory. In my program, each time i pring getFreeHeap() it is reduced by 2000 approximately and is never cleared or reset, when it is not sufficient or below 2000 xTaskCreate returns -1.

After reading a lot of forums I could not find a way to clear the memory to create a task, can anyone guide me achieving this ?

code snippet

void createTsk(){
  SerialDebug.print("available Heap size: ");
  SerialDebug.println(ESP.getFreeHeap());

  BaseType_t xBy = xTaskCreate(taskPriorityOne, "TaskOne", 20240, NULL, 1, &thOne);
  SerialDebug.println("Return Val : ");
  SerialDebug.println(xBy);
}

void taskPriorityOne(void *paramter)
{
   SerialDebug.println("Prio 1 task Initiated");
   threadTask(priorityOneQue, "task1", thOne);
}

void threadTask(QueueHandle_t priorityQue, String taskName, TaskHandle_t th)
{
  xQueueReceive(priorityQue, &taskdataholder, portMAX_DELAY);
  ongoingProcess = taskdataholder;
  furtherExecutionHttp(taskdataholder, fnm, taskName, th);
}

void furtherExecutionHttp(DataHolder *taskdataholder, String fnm, String 
taskName, TaskHandle_t th)
{
   String response = httpRequest(taskdataholder->protocol, taskdataholder- 
   >host, taskdataholder->port, taskdataholder->url, taskdataholder->body, 
   fnm);

  delay(10);

  free(taskdataholder);
  SerialDebug.println("Releasing memory..\n");

  vTaskDelete(th);
}
code added
Source Link
Androing
  • 71
  • 1
  • 2
  • 5

I am using Free RTOS on esp32 in my program. However at some point of time when I execute xTaskCreate() it returns -1 , which error is could_not_allocate_required_memory. In my program, each time i pring getFreeHeap() it is reduced by 2000 approximately and is never cleared or reset, when it is not sufficient or below 2000 xTaskCreate returns -1.

After reading a lot of forums I could not find a way to clear the memory to create a task, can anyone guide me achieving this ?

code snippet

void createTsk(){
  SerialDebug.print("available Heap size: ");
  SerialDebug.println(ESP.getFreeHeap());

  BaseType_t xBy = xTaskCreate(taskPriorityOne, "TaskOne", 20240, NULL, 1, &thOne);
  SerialDebug.println("Return Val : ");
  SerialDebug.println(xBy);
}

void taskPriorityOne(void *paramter)
{
   SerialDebug.println("Prio 1 task Initiated");
   threadTask(priorityOneQue, "task1", thOne);
}

void threadTask(QueueHandle_t priorityQue, String taskName, TaskHandle_t th)
{

  xQueueReceive(priorityQue, &taskdataholder, portMAX_DELAY);
  ongoingProcess = taskdataholder;
  furtherExecutionHttp(taskdataholder, fnm, taskName, th);

}

void furtherExecutionHttp(DataHolder *taskdataholder, String fnm, String 
taskName, TaskHandle_t th)
{

   String response = httpRequest(taskdataholder->protocol, taskdataholder- 
   >host, taskdataholder->port, taskdataholder->url, taskdataholder->body, 
   fnm);

  delay(10);

  free(taskdataholder);
  SerialDebug.println("Releasing memory..\n");

  vTaskDelete(th);
}

I am using Free RTOS on esp32 in my program. However at some point of time when I execute xTaskCreate() it returns -1 , which error is could_not_allocate_required_memory.

After reading a lot of forums I could not find a way to clear the memory to create a task, can anyone guide me achieving this ?

I am using Free RTOS on esp32 in my program. However at some point of time when I execute xTaskCreate() it returns -1 , which error is could_not_allocate_required_memory. In my program, each time i pring getFreeHeap() it is reduced by 2000 approximately and is never cleared or reset, when it is not sufficient or below 2000 xTaskCreate returns -1.

After reading a lot of forums I could not find a way to clear the memory to create a task, can anyone guide me achieving this ?

code snippet

void createTsk(){
  SerialDebug.print("available Heap size: ");
  SerialDebug.println(ESP.getFreeHeap());

  BaseType_t xBy = xTaskCreate(taskPriorityOne, "TaskOne", 20240, NULL, 1, &thOne);
  SerialDebug.println("Return Val : ");
  SerialDebug.println(xBy);
}

void taskPriorityOne(void *paramter)
{
   SerialDebug.println("Prio 1 task Initiated");
   threadTask(priorityOneQue, "task1", thOne);
}

void threadTask(QueueHandle_t priorityQue, String taskName, TaskHandle_t th)
{

  xQueueReceive(priorityQue, &taskdataholder, portMAX_DELAY);
  ongoingProcess = taskdataholder;
  furtherExecutionHttp(taskdataholder, fnm, taskName, th);

}

void furtherExecutionHttp(DataHolder *taskdataholder, String fnm, String 
taskName, TaskHandle_t th)
{

   String response = httpRequest(taskdataholder->protocol, taskdataholder- 
   >host, taskdataholder->port, taskdataholder->url, taskdataholder->body, 
   fnm);

  delay(10);

  free(taskdataholder);
  SerialDebug.println("Releasing memory..\n");

  vTaskDelete(th);
}
Source Link
Androing
  • 71
  • 1
  • 2
  • 5
Loading