Common/MemArena: Set MAP_NORESERVE in LazyMemoryRegion on Linux.
This commit is contained in:
parent
1a0f0e7e96
commit
7869abf0e6
|
@ -117,6 +117,12 @@ LazyMemoryRegion::~LazyMemoryRegion()
|
||||||
Release();
|
Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined MAP_NORESERVE && (defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__)
|
||||||
|
// BSD does not implement MAP_NORESERVE, so define the flag to nothing.
|
||||||
|
// See https://reviews.freebsd.org/rS273250
|
||||||
|
#define MAP_NORESERVE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
void* LazyMemoryRegion::Create(size_t size)
|
void* LazyMemoryRegion::Create(size_t size)
|
||||||
{
|
{
|
||||||
ASSERT(!m_memory);
|
ASSERT(!m_memory);
|
||||||
|
@ -124,7 +130,8 @@ void* LazyMemoryRegion::Create(size_t size)
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
void* memory = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
void* memory =
|
||||||
|
mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0);
|
||||||
if (memory == MAP_FAILED)
|
if (memory == MAP_FAILED)
|
||||||
{
|
{
|
||||||
NOTICE_LOG_FMT(MEMMAP, "Memory allocation of {} bytes failed.", size);
|
NOTICE_LOG_FMT(MEMMAP, "Memory allocation of {} bytes failed.", size);
|
||||||
|
@ -142,7 +149,7 @@ void LazyMemoryRegion::Clear()
|
||||||
ASSERT(m_memory);
|
ASSERT(m_memory);
|
||||||
|
|
||||||
void* new_memory = mmap(m_memory, m_size, PROT_READ | PROT_WRITE,
|
void* new_memory = mmap(m_memory, m_size, PROT_READ | PROT_WRITE,
|
||||||
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
|
MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_FIXED, -1, 0);
|
||||||
ASSERT(new_memory == m_memory);
|
ASSERT(new_memory == m_memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue