diff --git a/src/sys/mem/heap.rs b/src/sys/mem/heap.rs index cdbe5836..1d4931db 100644 --- a/src/sys/mem/heap.rs +++ b/src/sys/mem/heap.rs @@ -12,18 +12,13 @@ static ALLOCATOR: LockedHeap = LockedHeap::empty(); pub const HEAP_START: u64 = 0x4444_4444_0000; -fn max_memory() -> usize { - // Default to 32 MB - option_env!("MOROS_MEMORY").unwrap_or("32").parse::().unwrap() << 20 -} - pub fn init_heap() -> Result<(), MapToError> { let mapper = super::mapper(); let mut frame_allocator = super::frame_allocator(); // Use half of the memory for the heap caped to 16 MB by default // because the allocator is slow. - let heap_size = (cmp::min(super::memory_size(), max_memory()) / 2) as u64; + let heap_size = (cmp::min(super::memory_size(), heap_max()) / 2) as u64; let heap_start = VirtAddr::new(HEAP_START); sys::process::init_process_addr(HEAP_START + heap_size); @@ -51,6 +46,11 @@ pub fn init_heap() -> Result<(), MapToError> { Ok(()) } +fn heap_max() -> usize { + // Default to 32 MB + option_env!("MOROS_MEMORY").unwrap_or("32").parse::().unwrap() << 20 +} + pub fn heap_size() -> usize { ALLOCATOR.lock().size() }