Reserves a contiguous slice of virtual memory committing just a portion of it. More...
#include <VirtualMemory.h>
Public Member Functions | |
| VirtualMemory (const VirtualMemory &)=delete | |
| VirtualMemory (VirtualMemory &&)=delete | |
| VirtualMemory & | operator= (const VirtualMemory &)=delete |
| VirtualMemory & | operator= (VirtualMemory &&)=delete |
| bool | reserve (size_t maxCapacityInBytes) |
| Reserves a large block of virtual memory of size maxCapacityInBytes. | |
| void | release () |
| Reclaims the entire virtual memory block (reserved with VirtualMemory::reserve) | |
| bool | commit (size_t sizeInBytes) |
| Ensures at least sizeInBytes to be committed / accessible from the large maxCapacityInBytes block. | |
| bool | shrink (size_t sizeInBytes) |
| Reclaims all unused pages past sizeInBytes (previously committed with VirtualMemory::commit) | |
| size_t | size () const |
| Returns how many bytes are currently committed / accessible. | |
| size_t | capacity () const |
| Returns how many bytes are currently reserved. | |
| void * | data () |
| Returns a pointer to the start of the reserved virtual memory. | |
| const void * | data () const |
| Returns a pointer to the start of the reserved virtual memory. | |
Static Public Member Functions | |
| static size_t | roundUpToPageSize (size_t size) |
| Round up the passed in size to system memory page size. | |
| static size_t | getPageSize () |
| Obtains system memory page size. | |
Reserves a contiguous slice of virtual memory committing just a portion of it.
This class is useful on 64-bit systems where the address space is so large that it's feasible reserving large chunks of memory to commit and de-commit (shrink) as needed.
Reservation ensures that the returned address will not change and will be sized in multiples of system page size.
|
inlinenodiscard |
Returns how many bytes are currently reserved.
|
nodiscard |
Ensures at least sizeInBytes to be committed / accessible from the large maxCapacityInBytes block.
| sizeInBytes | Indicates how much of the reserved virtual address space that must be accessible |
|
inlinenodiscard |
Returns a pointer to the start of the reserved virtual memory.
|
inlinenodiscard |
Returns a pointer to the start of the reserved virtual memory.
|
staticnodiscard |
Obtains system memory page size.
| void SC::VirtualMemory::release | ( | ) |
Reclaims the entire virtual memory block (reserved with VirtualMemory::reserve)
|
nodiscard |
Reserves a large block of virtual memory of size maxCapacityInBytes.
| maxCapacityInBytes | Size of the reserved amount of virtual address space |
Round up the passed in size to system memory page size.
|
nodiscard |
Reclaims all unused pages past sizeInBytes (previously committed with VirtualMemory::commit)
|
inlinenodiscard |
Returns how many bytes are currently committed / accessible.