+/*
+ * Release memory for Valgrind.
+ */
+static void cleanup(struct ui_psensor *ui)
+{
+ g_mutex_lock(ui->sensors_mutex);
+
+ psensor_cleanup();
+
+#ifdef HAVE_NVIDIA
+ nvidia_cleanup();
+#endif
+#ifdef HAVE_LIBATIADL
+ amd_cleanup();
+#endif
+#ifdef HAVE_REMOTE_SUPPORT
+ rsensor_cleanup();
+#endif
+
+ psensor_list_free(ui->sensors);
+ ui->sensors = NULL;
+
+#if defined(HAVE_APPINDICATOR) || defined(HAVE_APPINDICATOR_029)
+ ui_appindicator_cleanup();
+#endif
+
+ ui_status_cleanup();
+
+ g_mutex_unlock(ui->sensors_mutex);
+
+ config_cleanup();
+
+ log_debug("Cleanup done, closing log");
+
+ log_close();
+}
+