From f478fa843d5dcaf797b19e826149ebc618b5bd61 Mon Sep 17 00:00:00 2001 From: XMRig Date: Mon, 21 Jan 2019 17:27:45 +0700 Subject: [PATCH] Better fix for memory allocation, thanks @SChernykh. --- src/Mem.cpp | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/Mem.cpp b/src/Mem.cpp index 85a3a832..76114745 100644 --- a/src/Mem.cpp +++ b/src/Mem.cpp @@ -41,19 +41,9 @@ MemInfo Mem::create(cryptonight_ctx **ctx, xmrig::Algo algorithm, size_t count) MemInfo info; info.size = cn_select_memory(algorithm) * count; -# ifndef XMRIG_NO_AEON - if (algorithm == xmrig::CRYPTONIGHT_LITE) { - info.size += info.size % cn_select_memory(); - } -# endif - -# ifndef XMRIG_NO_CN_PICO - if (algorithm == xmrig::CRYPTONIGHT_PICO) { - info.size = cn_select_memory(); - } -# endif - - info.pages = info.size / cn_select_memory(); + constexpr const size_t align_size = 2 * 1024 * 1024; + info.size = ((info.size + align_size - 1) / align_size) * align_size; + info.pages = info.size / align_size; allocate(info, m_enabled);