summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-12-02 17:36:10 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-12-02 17:36:10 +0100
commit7970b594d57c12829d9c22f396100395755b8a1d (patch)
treee1f3b5bae8903b44e6be4d86aee7bde1b4385e8f
parent0e34b7d65ed86b58b29df0bf20dda411bf42e20c (diff)
downloadserenity-7970b594d57c12829d9c22f396100395755b8a1d.zip
SystemMonitor: Update the process memory map once every second
-rw-r--r--Applications/SystemMonitor/ProcessMemoryMapWidget.cpp8
-rw-r--r--Applications/SystemMonitor/ProcessMemoryMapWidget.h3
2 files changed, 11 insertions, 0 deletions
diff --git a/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp b/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp
index a30f7f9d98..8b592a5999 100644
--- a/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp
+++ b/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp
@@ -1,4 +1,5 @@
#include "ProcessMemoryMapWidget.h"
+#include <LibCore/CTimer.h>
#include <LibGUI/GBoxLayout.h>
#include <LibGUI/GJsonArrayModel.h>
#include <LibGUI/GTableView.h>
@@ -30,6 +31,7 @@ ProcessMemoryMapWidget::ProcessMemoryMapWidget(GWidget* parent)
});
pid_vm_fields.empend("name", "Name", TextAlignment::CenterLeft);
m_table_view->set_model(GJsonArrayModel::create({}, move(pid_vm_fields)));
+ m_timer = CTimer::construct(1000, [this] { refresh(); }, this);
}
ProcessMemoryMapWidget::~ProcessMemoryMapWidget()
@@ -43,3 +45,9 @@ void ProcessMemoryMapWidget::set_pid(pid_t pid)
m_pid = pid;
static_cast<GJsonArrayModel*>(m_table_view->model())->set_json_path(String::format("/proc/%d/vm", pid));
}
+
+void ProcessMemoryMapWidget::refresh()
+{
+ if (m_pid != -1)
+ m_table_view->model()->update();
+}
diff --git a/Applications/SystemMonitor/ProcessMemoryMapWidget.h b/Applications/SystemMonitor/ProcessMemoryMapWidget.h
index db09ddc454..8d4081635b 100644
--- a/Applications/SystemMonitor/ProcessMemoryMapWidget.h
+++ b/Applications/SystemMonitor/ProcessMemoryMapWidget.h
@@ -2,6 +2,7 @@
#include <LibGUI/GWidget.h>
+class CTimer;
class GTableView;
class ProcessMemoryMapWidget final : public GWidget {
@@ -10,9 +11,11 @@ public:
virtual ~ProcessMemoryMapWidget() override;
void set_pid(pid_t);
+ void refresh();
private:
explicit ProcessMemoryMapWidget(GWidget* parent);
RefPtr<GTableView> m_table_view;
pid_t m_pid { -1 };
+ RefPtr<CTimer> m_timer;
};