Skip to content

Commit 72e663c

Browse files
committed
clarify the behavior of available() API.
Signed-off-by: ylzh10 <[email protected]>
1 parent 54fc3b8 commit 72e663c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/address_allocator.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ pub struct AddressAllocator {
2929
// tree will represent a memory location and can have two states either
3030
// `NodeState::Free` or `NodeState::Allocated`.
3131
interval_tree: IntervalTree,
32-
// Available memory space
32+
// Available free memory space in the address space.
33+
// NOTE that due to fragmentations, |available| may not give the actual
34+
// available (contiguous) memory block that can be allocated in next
35+
// allocate() call.
3336
available: usize,
3437
}
3538

@@ -80,6 +83,9 @@ impl AddressAllocator {
8083
}
8184

8285
/// Returns the available memory size in this allocator.
86+
/// NOTE that due to fragmentations, it's not guaranteed that the next
87+
/// allocate() call after querying the available memory can succeed with
88+
/// allocating those available memories and it may still return OOM.
8389
pub fn available(&self) -> usize {
8490
self.available
8591
}

0 commit comments

Comments
 (0)