File indexing completed on 2024-05-19 03:49:42

0001 /*
0002     File                 : MemoryWidget.cpp
0003     Project              : LabPlot
0004     Description          : widget showing the amount of memory consumed by the process
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2018 Alexander Semke <alexander.semke@web.de>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 
0011 #include "MemoryWidget.h"
0012 #include "tools/getRSS.h"
0013 
0014 #include <KLocalizedString>
0015 
0016 MemoryWidget::MemoryWidget(QWidget* parent)
0017     : QLabel(parent) {
0018     connect(&m_timer, &QTimer::timeout, this, &MemoryWidget::refreshMemoryInfo);
0019     refreshMemoryInfo();
0020     m_timer.start(2000);
0021 }
0022 
0023 void MemoryWidget::refreshMemoryInfo() {
0024     size_t used = getCurrentRSS() / 1024 / 1024;
0025     size_t peak = getPeakRSS() / 1024 / 1024;
0026     setText(i18n("Memory used %1 MB, peak %2 MB", used, peak));
0027 }