add a hook to ResourceLimiter to detect memory grow failure.
* allow the ResourceLimiter to reject a memory grow before the memory's own maximum. * add a hook so a ResourceLimiter can detect any reason that a memory grow fails, including if the OS denies additional memory * add tests for this new functionality. I only took the time to test the OS denial on Linux, it should be possible on Mac OS as well but I don't have a test setup. I have no idea how to do this on windows.
This commit is contained in:
@@ -62,7 +62,7 @@ mod not_for_windows {
|
||||
Some(self.size - self.guard_size)
|
||||
}
|
||||
|
||||
fn grow_to(&mut self, new_size: usize) -> Option<()> {
|
||||
fn grow_to(&mut self, new_size: usize) -> Result<(), anyhow::Error> {
|
||||
println!("grow to {:x}", new_size);
|
||||
let delta = new_size - self.used_wasm_bytes;
|
||||
unsafe {
|
||||
@@ -73,7 +73,7 @@ mod not_for_windows {
|
||||
|
||||
*self.glob_bytes_counter.lock().unwrap() += delta;
|
||||
self.used_wasm_bytes = new_size;
|
||||
Some(())
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn as_ptr(&self) -> *mut u8 {
|
||||
|
||||
Reference in New Issue
Block a user