Tools: Fix memory calculations of idf_size.py Closes IDF-3246 and IDF-2434 See merge request espressif/esp-idf!14347