fix: reduce size of memory map
This commit is contained in:
@@ -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);
|
||||||
|
|
||||||
|
|||||||
@@ -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<'_> {
|
||||||
|
|||||||
Reference in New Issue
Block a user