[Solved] sdCard (sdmmc / 1 bit mode) memory leak (16-28 bytes) on 2nd unmount

plusorc
Posts: 41
Joined: Sat Nov 09, 2019 6:27 am

[Solved] sdCard (sdmmc / 1 bit mode) memory leak (16-28 bytes) on 2nd unmount

Postby plusorc » Tue Apr 23, 2024 1:52 pm

In brief words

- We have to mount and un-mount sdCard on regular basis
- First time we do this -> no leak
- 2nd time mounting doesn't leak memory either
- 2nd un-mount of the sdCard leaks memory

Chip : ESP32 (rev 1)
IDF : ESP-IDF v5.1.3-416-gd23b7a0361

Reproduce Code
  1. #include "esp_vfs_fat.h"
  2. #include "freertos/portmacro.h"
  3. #include "sdmmc_cmd.h"
  4. #include "driver/sdmmc_host.h"
  5.  
  6. #include <stdint.h>
  7. #include <stdio.h>
  8. #include <string.h>
  9. #include <sys/stat.h>
  10. #include <sys/unistd.h>
  11. #include <dirent.h>
  12.  
  13. #define MAX_CHAR_SIZE 128
  14.  
  15. static const char *TAG = "SPI BUS Aquisition : ";
  16.  
  17. #define MOUNT_POINT "/sdcard"
  18. #define Flash_Access_Frequency CONFIG_HOST_MAX_FREQUENCY
  19.  
  20. #define SPI_THRESHOLD CONFIG_SPI_BUS_TIME_THRESHOLD
  21. #define SPI_TASK_FREQUENCY CONFIG_SPI_BUS_TASK_FREQUENCY
  22.  
  23.  
  24. sdmmc_card_t *card;
  25. sdmmc_host_t host = SDSPI_HOST_DEFAULT();
  26. const char mount_point[] = MOUNT_POINT;
  27.  
  28. volatile int64_t start_time = 0 ;
  29. volatile int64_t elapsed_time = 0 ;
  30. bool Can_TakeOver_SPI_BUS = false ;
  31.  
  32.  
  33. int List_Files_ON_Flash()
  34. {
  35.   DIR *d ;
  36.   struct dirent *dir;
  37.   d = opendir(MOUNT_POINT);
  38.   if (d)
  39.   {
  40.     printf("###############################\n");
  41.     printf("### Listing Files on Flash ..\n");
  42.     printf("###############################\n");
  43.    
  44.     int rank = 1 ;
  45.     while ((dir = readdir(d)) != NULL)
  46.       {
  47.         printf("%d. %s\n",rank, dir->d_name);
  48.         rank += 1;
  49.       }
  50.  
  51.     printf("###############################\n\n");
  52.     closedir(d);
  53.  
  54.     ESP_LOGI(TAG, "File written");
  55.   }
  56.   return 0;
  57. }
  58.  
  59. int Init_SPI_BUS()
  60. {
  61.   esp_err_t ret;
  62.  
  63.   esp_vfs_fat_sdmmc_mount_config_t mount_config = {
  64.       .format_if_mount_failed = false,
  65.       .max_files = 5,
  66.       .allocation_unit_size = 16 * 1024};
  67.  
  68.   ESP_LOGI(TAG, "Initializing SD card");
  69.  
  70.   ESP_LOGI(TAG, "Using SPI peripheral");
  71.  
  72.   sdmmc_host_t host = SDMMC_HOST_DEFAULT();
  73.   host.max_freq_khz = Flash_Access_Frequency ; // 1000;
  74.  
  75.   // This initializes the slot without card detect (CD) and write protect (WP) signals.
  76.   // Modify slot_config.gpio_cd and slot_config.gpio_wp if your board has these signals.
  77.   sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
  78.  
  79.   // Set bus width to use:
  80.   slot_config.width = 1;
  81.   slot_config.flags |= SDMMC_SLOT_FLAG_INTERNAL_PULLUP;
  82.  
  83.     ESP_LOGI(TAG, "Mounting filesystem");
  84.     ret = esp_vfs_fat_sdmmc_mount(mount_point, &host, &slot_config, &mount_config, &card);
  85.  
  86.   if (ret != ESP_OK)
  87.   {
  88.     if (ret == ESP_FAIL)
  89.     {
  90.       ESP_LOGE(TAG, "Failed to mount filesystem. "
  91.                     "If you want the card to be formatted, set the "
  92.                     "CONFIG_FORMAT_IF_MOUNT_FAILED menuconfig option.");
  93.     }
  94.     else
  95.     {
  96.       ESP_LOGE(TAG,
  97.                "Failed to initialize the card (%s). "
  98.                "Make sure SD card lines have pull-up resistors in place.",
  99.                esp_err_to_name(ret));
  100.     }
  101.     return -1 ;
  102.   }
  103.   ESP_LOGI(TAG, "Filesystem mounted");
  104.  
  105.   printf("###############################\n");
  106.   // Card has been initialized, print its properties
  107.   sdmmc_card_print_info(stdout, card);
  108.  
  109.   printf("###############################\n");
  110.  
  111.   return 0 ;
  112. }
  113.  
  114. int Free_SPI_BUS()
  115. {
  116.   if (esp_vfs_fat_sdcard_unmount(mount_point, card) == ESP_OK)
  117.     ESP_LOGI(TAG, "\033[1;33mSuccessfully Unmounted sdCard !\033[0m");
  118.  
  119.   return 0;
  120. }
  121.  
  122. void Task_TakeOver_SPI_BUS(void* arrow)
  123. {
  124.   for(;;)
  125.     {
  126.         ESP_LOGI(TAG, "###### Exceeded Threshold Time #######");
  127.  
  128.         Init_SPI_BUS();
  129.         // List_Files_ON_Flash();
  130.         Free_SPI_BUS();
  131.        
  132.         heap_caps_check_integrity_all(true);
  133.                 ESP_LOGI(TAG,"\033[1;33m ************************\033[0m");
  134.                 ESP_LOGI(TAG,"\033[1;33m Free memory: %0.3f Kb\033[0m ", esp_get_free_heap_size()/1000.0);
  135.                 ESP_LOGI(TAG,"\033[1;33m ************************\033[0m");
  136.  
  137.       vTaskDelay( 2000 / portTICK_PERIOD_MS);
  138.     }
  139. }
  140.  
  141. void app_main(void)
  142. {
  143.   // esp_log_level_set("gpio", ESP_LOG_ERROR);
  144.   // esp_log_level_set("sdspi_transaction", ESP_LOG_ERROR);
  145.  
  146.   xTaskCreate(Task_TakeOver_SPI_BUS, "xTask_SPI", 2048, NULL, 5, NULL);
  147. }

Memory log from MQTT (from the original project)
Chip Started
Wifi Started
Getting Auth Info , Memory : 161Kb
Getting Auth Info ..... Success !, Memory : 171Kb
Free Memory at ALL_FILES_UPLOADED , Memory : 175.068 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 175.056 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 175.040 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 175.024 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 175.008 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.992 bytes
!Ahora mismo : Sun Apr 21 01:39:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.976 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.960 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.944 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.924 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.904 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.880 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.864 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.840 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.824 bytes
!Ahora mismo : Sun Apr 21 01:40:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.808 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.792 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.988 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.972 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.956 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.940 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.924 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.900 bytes
!Ahora mismo : Sun Apr 21 01:41:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.884 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.868 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.852 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.836 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.812 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.796 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.780 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.764 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.748 bytes
!Ahora mismo : Sun Apr 21 01:42:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.732 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.716 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.696 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.680 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.664 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.648 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.632 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.616 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.476 bytes
!Ahora mismo : Sun Apr 21 01:43:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.584 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.568 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.552 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.536 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.520 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.504 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.488 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.472 bytes
!Ahora mismo : Sun Apr 21 01:44:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.456 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.424 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.408 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.392 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.376 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.360 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.344 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.328 bytes
!Ahora mismo : Sun Apr 21 01:45:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.312 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.296 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.280 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.264 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.248 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.232 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.216 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.196 bytes
!Ahora mismo : Sun Apr 21 01:46:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.180 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.164 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.148 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.132 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.104 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.088 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.072 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.056 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.040 bytes
!Ahora mismo : Sun Apr 21 01:47:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.024 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.008 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.992 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.964 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.948 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.932 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.916 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.900 bytes
!Ahora mismo : Sun Apr 21 01:48:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 173.884 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.868 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.852 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.836 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.820 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.804 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.788 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.772 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.632 bytes
!Ahora mismo : Sun Apr 21 01:49:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 173.740 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.724 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.708 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.692 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.676 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.660 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.644 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.628 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.612 bytes
!Ahora mismo : Sun Apr 21 01:50:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 173.596 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.580 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.564 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.548 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.532 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.516 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.500 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.484 bytes
!Ahora mismo : Sun Apr 21 01:51:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 173.468 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.452 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.436 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.420 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.404 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.388 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.372 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.356 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.340 bytes
!Ahora mismo : Sun Apr 21 01:52:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 173.324 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.308 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.292 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.276 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.260 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.244 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.228 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.212 bytes
!Ahora mismo : Sun Apr 21 01:53:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 173.196 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.180 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.164 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.148 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.132 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.116 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.100 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.084 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.068 bytes
!Ahora mismo : Sun Apr 21 01:54:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 173.052 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.036 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.020 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 173.004 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.988 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.972 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.956 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.924 bytes
!Ahora mismo : Sun Apr 21 01:55:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 172.900 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.884 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.744 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.852 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.836 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.820 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.804 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.788 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.772 bytes
!Ahora mismo : Sun Apr 21 01:56:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 172.756 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.740 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.716 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.700 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.684 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.668 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.652 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.636 bytes
!Ahora mismo : Sun Apr 21 01:57:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 172.620 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.604 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.588 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.572 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.556 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.540 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.524 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.508 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.492 bytes
!Ahora mismo : Sun Apr 21 01:58:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 172.476 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.460 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.444 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.428 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.396 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.256 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.364 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.348 bytes
!Ahora mismo : Sun Apr 21 01:59:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 172.332 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.192 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.300 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.280 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.264 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.248 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.232 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.216 bytes
!Ahora mismo : Sun Apr 21 02:00:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 172.200 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.184 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.168 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.152 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.136 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 171.996 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.104 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.076 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.060 bytes
!Ahora mismo : Sun Apr 21 02:01:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 172.044 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.028 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 172.012 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 171.996 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 171.980 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 171.964 bytes


This keeps happening till the memory is eroded
My Tests show that this only happens after the 2nd Un-mount of sdCard
I have traced the free memory after 1st Time Mount and then Release
and after the 2nd Time mount , and it typically deducted about 27k
but then after the 2nd Un-mount the above behavior happens

I included a Test project
SPI_Aquisition.zip
Test Project
(198.09 KiB) Downloaded 94 times
mem_loss.png
mem_loss.png (239.84 KiB) Viewed 896 times
I hope I'm doing something wrong here , cause we do need this to work
Last edited by plusorc on Wed Apr 24, 2024 2:35 pm, edited 1 time in total.

RathiSonika
Posts: 11
Joined: Thu Jun 22, 2023 2:58 pm

Re: sdCard (sdmmc / 1 bit mode) memory leak (16-28 bytes) on 2nd unmount

Postby RathiSonika » Wed Apr 24, 2024 8:00 am

Hi @plusorc, Could you please try the same example on IDF v5.2? The issue you are facing has already been addressed in this version.

plusorc
Posts: 41
Joined: Sat Nov 09, 2019 6:27 am

Re: [Solved] sdCard (sdmmc / 1 bit mode) memory leak (16-28 bytes) on 2nd unmount

Postby plusorc » Wed Apr 24, 2024 2:40 pm

Thank You so much for your help
Switching to v5.2.1 solved the problem
Chip Started
Wifi Started
Getting Auth Info , Memory : 159Kb
Getting Auth Info ..... Success !, Memory : 170Kb
Start Sending File : file_1024000.txt, Size : 1024000
!Ahora mismo : Wed Apr 24 14:13:01 UTC 2024, ¡Hola Mundo!
Finished Sending File : file_1024000.txt, Size : 1024000, Result -> Success !, Memory : 162Kb
Free Memory at ALL_FILES_UPLOADED , Memory : 174.184 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.208 bytes
!Ahora mismo : Wed Apr 24 14:14:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.184 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.184 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.184 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.184 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.216 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
!Ahora mismo : Wed Apr 24 14:15:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
!Ahora mismo : Wed Apr 24 14:16:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
!Ahora mismo : Wed Apr 24 14:17:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.440 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.424 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
!Ahora mismo : Wed Apr 24 14:18:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
!Ahora mismo : Wed Apr 24 14:19:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
!Ahora mismo : Wed Apr 24 14:20:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.400 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
!Ahora mismo : Wed Apr 24 14:21:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
!Ahora mismo : Wed Apr 24 14:22:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
!Ahora mismo : Wed Apr 24 14:23:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
!Ahora mismo : Wed Apr 24 14:24:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
!Ahora mismo : Wed Apr 24 14:25:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
!Ahora mismo : Wed Apr 24 14:26:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.412 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.288 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.280 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.776 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.204 bytes
!Ahora mismo : Wed Apr 24 14:27:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.204 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.204 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.204 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.204 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.204 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.204 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.204 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.204 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.208 bytes
!Ahora mismo : Wed Apr 24 14:28:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.196 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.208 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.420 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.420 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.420 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.420 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.420 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.420 bytes
!Ahora mismo : Wed Apr 24 14:29:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.420 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.420 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.420 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.420 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.420 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.420 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.420 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.420 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
!Ahora mismo : Wed Apr 24 14:30:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
!Ahora mismo : Wed Apr 24 14:31:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
!Ahora mismo : Wed Apr 24 14:32:01 UTC 2024, ¡Hola Mundo!
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
Free Memory at ALL_FILES_UPLOADED , Memory : 174.416 bytes
!Ahora mismo : Wed Apr 24 14:33:01 UTC 2024, ¡Hola Mundo!
for the record if any one is reading this , it wasn't the 2nd unmount , it was the cycle of mount & unmount that leaked 16-28 bytes

Who is online

Users browsing this forum: No registered users and 189 guests