fix: reduce size of memory map

This commit is contained in:
2024-04-22 15:02:11 +02:00
parent 6edbb046fa
commit e649e2b595
2 changed files with 5 additions and 4 deletions

View File

@@ -3,10 +3,10 @@ use std::{
usize, usize,
}; };
use libc::{c_char, c_void, ftruncate, memfd_create, mmap, MAP_SHARED, PROT_READ, PROT_WRITE}; use libc::{c_char, c_void, ftruncate, memfd_create, mmap, MAP_FAILED, MAP_SHARED, PROT_READ, PROT_WRITE};
pub(crate) const MEMFD_INITIAL_SIZE: usize = 1024 * 1024 * 4; pub(crate) const MEMFD_INITIAL_SIZE: usize = 1024 * 1024;
const MMAP_SIZE: usize = 1024 * 1024 * 1024; const MMAP_SIZE: usize = 1024 * 1024;
pub(crate) static BUMP_ALLOCATOR: LazyLock<Mutex<BumpAllocator>> = pub(crate) static BUMP_ALLOCATOR: LazyLock<Mutex<BumpAllocator>> =
LazyLock::new(|| unsafe { Mutex::new(BumpAllocator::new()) }); LazyLock::new(|| unsafe { Mutex::new(BumpAllocator::new()) });
@@ -41,7 +41,7 @@ impl BumpAllocator {
0, 0,
) as *mut u8; ) as *mut u8;
assert_ne!(start_of_mem, 0 as *mut u8); assert_ne!(start_of_mem, MAP_FAILED as *mut u8);
let end_of_mem = start_of_mem.byte_add(MEMFD_INITIAL_SIZE); let end_of_mem = start_of_mem.byte_add(MEMFD_INITIAL_SIZE);

View File

@@ -6,6 +6,7 @@ use std::{
use crate::allocator::ALLOCATOR; use crate::allocator::ALLOCATOR;
#[derive(Debug)]
pub struct SharedPtr<'a>(&'a mut [u8]); pub struct SharedPtr<'a>(&'a mut [u8]);
impl SharedPtr<'_> { impl SharedPtr<'_> {