From 1a819c61890ad940edf3d5f4cb1abb893d4e3e69 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 22 Aug 2018 21:49:57 +0200 Subject: [PATCH] Fixed memory leak --- src/workers/Hashrate.cpp | 11 +++++++++++ src/workers/Hashrate.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/workers/Hashrate.cpp b/src/workers/Hashrate.cpp index 2a750318..10fd8279 100644 --- a/src/workers/Hashrate.cpp +++ b/src/workers/Hashrate.cpp @@ -71,6 +71,17 @@ Hashrate::Hashrate(size_t threads, xmrig::Controller *controller) : } } +Hashrate::~Hashrate() +{ + for (size_t i = 0; i < m_threads; i++) { + delete [] m_counts[i]; + delete [] m_timestamps[i]; + } + delete [] m_counts; + delete [] m_timestamps; + delete [] m_top; +} + double Hashrate::calc(size_t ms) const { diff --git a/src/workers/Hashrate.h b/src/workers/Hashrate.h index e766f117..8b323a80 100644 --- a/src/workers/Hashrate.h +++ b/src/workers/Hashrate.h @@ -44,6 +44,7 @@ public: }; Hashrate(size_t threads, xmrig::Controller *controller); + ~Hashrate(); double calc(size_t ms) const; double calc(size_t threadId, size_t ms) const; void add(size_t threadId, uint64_t count, uint64_t timestamp);