Skip to content

Commit b5adcac

Browse files
authored
Don't panic on memory commit failure. (#154)
1 parent 62d6712 commit b5adcac

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

internal/alloc/alloc_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (m *mmappedMemory) Reallocate(size uint64) []byte {
4747
// Commit additional memory up to new bytes.
4848
err := unix.Mprotect(m.buf[com:new], unix.PROT_READ|unix.PROT_WRITE)
4949
if err != nil {
50-
panic(err)
50+
return nil
5151
}
5252

5353
// Update committed memory.

internal/alloc/alloc_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (m *virtualMemory) Reallocate(size uint64) []byte {
5656
// Commit additional memory up to new bytes.
5757
_, err := windows.VirtualAlloc(m.addr, uintptr(new), windows.MEM_COMMIT, windows.PAGE_READWRITE)
5858
if err != nil {
59-
panic(err)
59+
return nil
6060
}
6161

6262
// Update committed memory.

0 commit comments

Comments
 (0)