As suggested in another question, we have added destination path as db and autosave_interval as 3000, but after few days memory is getting reducing automatically.
Please let me know if there is any other solution to store in only db file.
The mosquitto broker does not support offloading the persistence store to an external database and the db file is just a backup of the in memory database in case the broker crashes or is shutdown.
If you have large numbers of messages queued for offline clients or large numbers of large retained messages then memory will be consumed.
The best you can do is set the
persistent_client_expiration option to remove queued messages for clients that have not logged on for a long time. Details of this option can be found in the mosquitto.conf man page.
Otherwise you will need to look at using a different broker that supports out of process storing of the persistence database. Something like mosca can be configured to use mongo or redis as a backing store.