-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
os-windowsstandard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.
Milestone
Description
Currently, the PageAllocator
does allocations aligned with std.mem.page_size
(4KB on Windows) using VirtualAlloc. Windows requires it's allocations to be aligned on 64KB boundaries, so everytime this allocator is used, up to 60KB of address space is wasted.
I made a small program to illustrate. All the addresses are 64KB apart (except the first one):
const alloc = std.heap.page_allocator;
for (0..16) |_| {
const block = try alloc.alloc(u8, 4096);
std.debug.print("{*}\n", .{block});
}
Outputs:
u8@2babf240000
u8@2babf360000
u8@2babf370000
u8@2babf380000
u8@2babf390000
u8@2babf4a0000
u8@2babf4b0000
u8@2babf4c0000
u8@2babf4d0000
u8@2babf4e0000
u8@2babf4f0000
u8@2babf500000
u8@2babf510000
u8@2babf520000
u8@2babf530000
u8@2babf540000
A simple solution would be to use Windows' allocation granularity instead of the page size, although this would commit at least 64KB every allocations instead of 4KB.
squeek502
Metadata
Metadata
Assignees
Labels
os-windowsstandard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.