# esp-idf-size

In the field of IoT development, memory constraints are a common challenge,
often requiring developers to optimize their application size. Whether it
involves ensuring the firmware fits within available flash memory or analyzing
impact of code changes on the final  binary size, effective firmware size
management is essential for resource efficiency.  The esp-idf-size tool
provides developers with the means to explore statically allocated RAM used by
the final binary firmware image generated by
[ESP-IDF](https://github.com/espressif/esp-idf) SDK for Espressif devices.

The `esp-idf-size` tool is included in the ESP-IDF and is installed
automatically. It can be accessed using the `idf.py` command or the
`idf_size.py` wrapper. The `idf.py` command provides access to the most
commonly used `esp-idf-size` commands and automatically sets some options for
user convenience, while the `idf_size.py` wrapper allows full access to all
`esp-idf-size` features. For more information on using `esp-idf-size` in
ESP-IDF, please refer to
[Minimizing Binary Size](https://docs.espressif.com/projects/esp-idf/en/stable/api-guides/performance/size.html).


The `esp-idf-size` package comes in two versions: legacy and refactored. The
refactored version, which is the default version used in ESP_IDF v5.3 and
later, retains backward compatibility with the options, making it easy to
switch between the two by setting the `ESP_IDF_SIZE_NG` environment variable,
available from ESP-IDF v5.0 onwards. However, the size report output
formats are different in the refactored version. You can also use the
refactored version by specifying the `--ng` option or by directly using the
`esp_idf_size.ng` subpackage. Here are some examples of how to use the
refactored version:

```sh
python -m esp_idf_size --ng --help
python -m esp_idf_size.ng --help
export ESP_IDF_SIZE_NG=1
python -m esp_idf_size --help
```

For more detailed information about the refactored version, please refer to the
documentation available [here](esp_idf_size/ng/docs/readme.md).
