Memory leakage in IDF function

ukrsms
Posts: 10
Joined: Tue Aug 20, 2019 11:30 am

Memory leakage in IDF function

Postby ukrsms » Wed Jan 29, 2020 2:26 pm

During debugging of my own code I found two functions that don't deallocate all the memory they used.
Memory leaked only after the first used of the function
here are the fubctions:
memory leak 20 Bytes

Code: Select all

ledc_fade_func_install(0);	
ledc_fade_func_uninstall();
and

memory leak 84 Bytes:

Code: Select all

esp_adc_cal_characteristics_t characters;
u8 calType=esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, ADC_WIDTH_BIT_12, 1100, &characters);
u32 voltage;
esp_adc_cal_get_voltage((adc_channel_t)1, &characters, &voltage);
Please, tell me whether I did something wrong, or it is a bug in IDF, or it is a normal operation of the functions?
Tested with IDF ver.4.1

ukrsms
Posts: 10
Joined: Tue Aug 20, 2019 11:30 am

Re: Memory leakage in IDF function

Postby ukrsms » Fri Feb 14, 2020 4:59 pm

after recent test I found one more function stealing memory:
esp_efuse_mac_get_default()
it steals 84 bytes after first calling

ESP_Sprite
Posts: 3118
Joined: Thu Nov 26, 2015 4:08 am

Re: Memory leakage in IDF function

Postby ESP_Sprite » Sat Feb 15, 2020 10:04 am

Thanks for the report, however, you're probably better off creating a Github issue for this, as it will automatically get tracked into the system.

ESP_Angus
Posts: 2020
Joined: Sun May 08, 2016 4:11 am

Re: Memory leakage in IDF function

Postby ESP_Angus » Tue Feb 18, 2020 4:34 am

ukrsms wrote:
Wed Jan 29, 2020 2:26 pm
Memory leaked only after the first used of the function
These may not be memory leaks as some types of data structures in IDF are allocated on first access ("lazy initialization") but are not deinitialized.

If you repeat the same init/deinit sequence multiple times, or call the same function multiple times, and the memory use goes up each time then this is definitely a memory leak.

If you need some tools to better analyze where allocations are happening, the heap tracing feature can help:
https://docs.espressif.com/projects/esp ... ap-tracing

Angus

Who is online

Users browsing this forum: No registered users and 12 guests