You're going to need to give a lot more detail!
https://community.st.com/t5/community-guidelines/how-to-write-your-question-to-maximize-your-chances-to-find-a/ta-p/575228
@ramazan_kavak wrote:
"Out of memory error." (-1) error occurs
Where, exactly, does it occur?
@ramazan_kavak wrote:
After publishing and subscribing for a certain period of time (30-40 minutes)
Sounds like you have a memory leak - ie, you keep allocating memory, but never release it.
You need to review your code (maybe also the LwIP documentation, and documentation for your MQTT library) to see where memory is being allocated, and check that it always gets released (de-allocated).
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.