ESP32 FreeRTOS memory allocation error

alas21
Posts: 1
Joined: Wed Oct 06, 2021 4:09 pm

ESP32 FreeRTOS memory allocation error

Postby alas21 » Wed Oct 06, 2021 4:16 pm

Hi,
I use xTaskCreate and when I use it twice it works properly but when I add one more xTaskCreate then I have error:
[E][ssl_client.cpp:36] _handle_error(): [start_ssl_client():207]: (-32512) SSL - Memory allocation failed
[E][WiFiClientSecure.cpp:133] connect(): start_ssl_client: -32512

What can be reason of that ? It used the whole available memory ?
  1.   xTaskCreate(led,"led",6000,NULL,1,NULL);
  2.   xTaskCreate(door,"door",6000,NULL,1,NULL);
  3.   xTaskCreate(ledonoff,"ledonoff",6000,NULL,1,NULL);
  4.  
  5.  
  6.  
  7. void door(void *parameter)
  8. {
  9.   int pauzaPir = 100000;
  10.  
  11.   for(;;){
  12.   fireStatusDoor = Firebase.getString("DOOR");                    
  13.  
  14.  
  15.   if (fireStatusDoor == "Close")
  16.   {                        
  17.     myservo.write(90);    
  18.   }
  19.                                                            
  20.   else if (fireStatusDoor == "Open")
  21.   {                
  22.     myservo.write(0);                                                        
  23.   }
  24.   else {
  25.     Serial.println("Wrong Credential! Please send open/close");
  26.    
  27.   }
  28. vTaskDelay(10);
  29. }
  30. vTaskDelete ( NULL );
  31. }
  32.  
  33.  
  34.  
  35. void ledonoff(void *parameter)
  36. {
  37.  
  38.  
  39.   for(;;){
  40.   fireStatusLed = Firebase.getString("LED_STATUS");  
  41.  
  42.   if (fireStatusLed == "ON")
  43.   {                        
  44.     digitalWrite(led_1, HIGH);                                                        
  45.   }
  46.  
  47.   else if (fireStatusLed == "OFF")
  48.   {            
  49.     digitalWrite(led_1, LOW);  
  50.   }
  51.  
  52.   else
  53.   {
  54.     Serial.println("Wrong Credential! Please send ON/OFF");
  55.    
  56.   }
  57.   vTaskDelay(10);
  58.   }
  59.   vTaskDelete ( NULL );
  60. }
  61.  
  62.  
  63.  
  64. void led(void *parameter)
  65. {
  66. int led_r;
  67. int led_g;
  68. int led_b;
  69.  
  70.    
  71. for(;;)
  72. {
  73.  
  74.  
  75. led_r=Firebase.getInt("LED_R");
  76.  
  77.  
  78.  led_g=Firebase.getInt("LED_G");
  79.  
  80. led_b=Firebase.getInt("LED_B");
  81.  
  82.  
  83. for (int i=0; i<num_led; i++){
  84.     leds[i] = CRGB(led_r, led_g, led_b );
  85.    
  86.     FastLED.show();
  87.    
  88.   }
  89.  vTaskDelay(10);
  90. }
  91. vTaskDelete ( NULL );
  92. }

Moderators Note: Fixed Codebox
Last edited by ESP_Dazz on Sat Oct 09, 2021 6:31 am, edited 1 time in total.
Reason: Fix Codebox

ESP_Dazz
Posts: 308
Joined: Fri Jun 02, 2017 6:50 am

Re: ESP32 FreeRTOS memory allocation error

Postby ESP_Dazz » Sat Oct 09, 2021 6:34 am

Don't think it should have as 3 tasks of 6K bytes each alone shouldn't be enough to consume all memory. You can call

Code: Select all

heap_caps_get_free_size()
in esp_heap_caps.h to get amount of free memory of a particular type/capability. Suggest you check the amount of memory with MALLOC_CAP_INTERNAL capability after each task creation to see if you are really running out of memory.

Who is online

Users browsing this forum: Bing [Bot] and 92 guests