Page 1 of 1

NVS and wear leveling

Posted: Fri Oct 20, 2017 2:25 pm
by kostyan5
Does NVS use wear leveling? If not, any plans to support it?

In our use case, we update a value in NVS every few mins and would hit 100,000 in about a year.

Re: NVS and wear leveling

Posted: Sat Oct 21, 2017 4:30 am
by kolban
Assuming NVS doesn't support wear leveling (and I don't believe it does), have you considered saving your data as records in one or more SPIFFS or FATFS files which do support wear leveling? It doesn't feel like it would be that difficult to create a wrapping API that would look/behave just like NVS but instead use a file system to hold your data.

Re: NVS and wear leveling

Posted: Sun Oct 22, 2017 6:06 am
by ESP_igrr
NVS keeps key-value pairs in a log-based structure, which works well for minimizing flash wear. It works best when you use small values, i.e. 8-64 bit integers. For blobs and strings, especially large ones (1k and above), performance is worse.
With integers, you can expect one flash sector to be erased once per every 125 updates of a value in key-value pair.