Skip to content

Commit

Permalink
commit virtual memory before copying (wasmerio#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
xmclark authored Feb 27, 2019
1 parent ff5e132 commit 95062d5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/runtime-core/src/sys/windows/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl Memory {

let protect = protection.to_protect_const();

let ptr = unsafe { VirtualAlloc(ptr::null_mut(), size, MEM_RESERVE, protect) };
let ptr = unsafe { VirtualAlloc(ptr::null_mut(), size, MEM_RESERVE | MEM_COMMIT, protect) };

if ptr.is_null() {
Err("unable to allocate memory".to_string())
Expand All @@ -57,7 +57,14 @@ impl Memory {

let size = round_up_to_page_size(size, page_size::get());

let ptr = unsafe { VirtualAlloc(ptr::null_mut(), size, MEM_RESERVE, PAGE_NOACCESS) };
let ptr = unsafe {
VirtualAlloc(
ptr::null_mut(),
size,
MEM_RESERVE | MEM_COMMIT,
PAGE_NOACCESS,
)
};

if ptr.is_null() {
Err(MemoryCreationError::VirtualMemoryAllocationFailed(
Expand Down

0 comments on commit 95062d5

Please sign in to comment.