The broker's memory has risen to the configured limit

Hi,
I have some questions about QoS and retain message.

In my project, set the connection parameter as QoS level 2 and retain message.
Broker set memory_limit.

Before the subscriber reconnect, publisher keep sending same topic messages causes broker memory to exceed memory_limit set.

The point that confuses me is why the publisher sending messages with the same topic causes the broker’s memory to increase.

If this cannot be avoided, are there other solutions to address this issue?

See my response here:

Thank you for your response.
In my project, I am using a Human Machine Interface (HMI) instead of a PC to run the MQTT broker, so the amount of data that can be stored in memory still has its limits.
I would like to ask, will the data stored in memory be automatically pushed to the subscribers after they reconnect, or is there a need for another method to retrieve and send the data?

Yes, that is correct. Since MQTT is not designed to be a database, but it acknowledges the problems of disconnecting, clients need to be able to have access to potentially missed information.

So QoS 1 & 2 hold information for a specific subscriber in the broker for the time needed. On reconnecting, all these messages will be sent and deleted from memory.

If you want to know a bit more about those principles, we have covered this in one of our courses in our MQTT academy: