MQTTX icon indicating copy to clipboard operation
MQTTX copied to clipboard

Exporting data can lead to instability and crashing the underlying OS due to memory starvation.

Open pulseuk-mh opened this issue 10 months ago • 2 comments

What did I do

Used export data to save a large number of MQTT messages as JSON.

What happened

It appears MQTTX extracts all the messages out of the database file (.config/MQTTX/MQTTX.db) and constructs a large in memory document that is then saved to disk of the users choice via a file dialog. If there are a large number of messages the in memory document uses all available memory and leads to an unstable or unresponsive system or OS crash. The current version of MQTTX will crash a system with 32GB of RAM when exporting a large dataset.

Expected

Ask the user for the format of the export, the file location and then stream the contents of the database in the correct format to the file at a record/message level without using an egregious amount of memory.

Environment

  • OS: OS version, Linux 5.4.0-58-generic
  • MQTTX version, V1.11.0

More detail

More detail include log information or screenshot

pulseuk-mh avatar Mar 11 '25 14:03 pulseuk-mh

This is indeed an issue that needs optimization. We'll improve the export functionality to use a streaming approach instead of loading everything into memory. Thank you for reporting this problem.

ysfscream avatar Mar 17 '25 03:03 ysfscream

Thank you.

pulseuk-mh avatar Mar 18 '25 11:03 pulseuk-mh

Welcome to try https://github.com/emqx/MQTTX/releases/tag/v1.12.1, where this issue has been addressed.

ysfscream avatar Oct 09 '25 02:10 ysfscream