mirror of
https://github.com/xmrig/xmrig.git
synced 2024-12-23 03:59:41 +00:00
Fix various memory leaks
This commit is contained in:
parent
f8f73b0cd7
commit
f6d45f7990
5 changed files with 19 additions and 1 deletions
|
@ -28,13 +28,19 @@
|
|||
|
||||
namespace xmrig {
|
||||
|
||||
static Storage<DnsUvBackend>* storage = nullptr;
|
||||
|
||||
Storage<DnsUvBackend>& DnsUvBackend::getStorage()
|
||||
{
|
||||
static Storage<DnsUvBackend>* storage = new Storage<DnsUvBackend>();
|
||||
if (storage == nullptr) storage = new Storage<DnsUvBackend>();
|
||||
return *storage;
|
||||
}
|
||||
|
||||
void DnsUvBackend::releaseStorage()
|
||||
{
|
||||
delete storage;
|
||||
}
|
||||
|
||||
static addrinfo hints{};
|
||||
|
||||
|
||||
|
@ -56,6 +62,7 @@ xmrig::DnsUvBackend::DnsUvBackend()
|
|||
xmrig::DnsUvBackend::~DnsUvBackend()
|
||||
{
|
||||
getStorage().release(m_key);
|
||||
releaseStorage();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ private:
|
|||
uintptr_t m_key;
|
||||
|
||||
static Storage<DnsUvBackend>& getStorage();
|
||||
void releaseStorage();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -316,6 +316,14 @@ xmrig::CnHash::CnHash()
|
|||
}
|
||||
|
||||
|
||||
xmrig::CnHash::~CnHash()
|
||||
{
|
||||
for (auto const& x : m_map) {
|
||||
delete m_map[x.first];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
xmrig::cn_hash_fun xmrig::CnHash::fn(const Algorithm &algorithm, AlgoVariant av, Assembly::Id assembly)
|
||||
{
|
||||
assert(cnHash.m_map.count(algorithm));
|
||||
|
|
|
@ -59,6 +59,7 @@ public:
|
|||
};
|
||||
|
||||
CnHash();
|
||||
virtual ~CnHash();
|
||||
|
||||
static cn_hash_fun fn(const Algorithm &algorithm, AlgoVariant av, Assembly::Id assembly);
|
||||
|
||||
|
|
|
@ -410,6 +410,7 @@ extern "C" {
|
|||
}
|
||||
|
||||
void randomx_release_cache(randomx_cache* cache) {
|
||||
delete cache->jit;
|
||||
delete cache;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue