There is a call in API to get the minimal size of heap (heap_caps_get_minimum_free_size)
AFAIK, this is the minimum size which happened during processing.
The idea is to find out, which function uses how much heap.
For example, create http-server and check this value, reset, create https and check, etc. etc.
Up to now, I did not work on this, with other words, no experience yet ;-)