Allocating a lot of memory
I'm running into some problems with memory allocations, and I think that maybe there is currently a limit of 1 MB for allocations? I'm basing this off this code here:
https://github.com/evmar/retrowin32/blob/baad4024058161bf0e759dee396c050d76546844/win32/system/src/memory.rs#L207-L212
The program I'm currently trying to run starts of by requesting 10_000_000 bytes of memory. Currently this panics, but I've changed the behavior locally to return a null pointer instead:
diff --git a/win32/system/src/heap.rs b/win32/system/src/heap.rs
index 7aa8986d..54aec4f4 100644
--- a/win32/system/src/heap.rs
+++ b/win32/system/src/heap.rs
@@ -31,7 +31,8 @@ impl Heap {
self.freelist
.borrow_mut()
.alloc(mem, size)
- .unwrap_or_else(|| panic!("heap size {:x} oom {:x}", self.size, size))
+ .unwrap_or(0)
+ // .unwrap_or_else(|| panic!("heap size {:x} oom {:x}", self.size, size))
}
pub fn size(&self, mem: Mem, addr: u32) -> u32 {
This actually lets the program continue quite a bit, starting to load in files from disk, until it hits another failed allocation of 10_008 bytes, whereupon the program handles this failure, prints an "INSUFFICIENT MEMORY" message, and shuts down...
I need to go to bed now, but any pointers that you have for how I can continue to investigate this would be much appreciated!