The other thing I found was that there are several problems with the default esp_mqtt code, and one that may be affecting you is that it allocates a 2kB data array on the heap during publish routines, but this is only used when there is a publish buffer overrun to clear the oldest message from the buffer. I changed this to a malloc inside the error handling if statement instead. This made a big difference to the amount of free heap I had at crucial moments
https://github.com/tuanpmt/esp_mqtt/issues/160
I also found I could set the SSL size to 4096 for MQTT and still publish everything I needed to, however I needed 5120 for HTTPS calls to a different server, so it's highly dependent on where you're connecting - have a play reducing the value for your site and you may find you can get away with less.