edsrzf / mmap-go

A portable mmap package for Go
BSD 3-Clause "New" or "Revised" License
938 stars 129 forks source link

windows: leaked handles after MapViewOfFile failure #29

Closed tmm1 closed 2 years ago

tmm1 commented 3 years ago

I'm seeing this on Windows 10 32-bit:

MapViewOfFile: Not enough memory resources are available to process this command.

This is fine because 32bit address space is limited and must be filling up. But then when I try to delete the file I was mapping, it fails too:

err removing file: 0000000002b4.zap, err: remove USA-MN53371-X.airings\store\0000000002b4.zap: Access is denied.

I think this is because the h handle is leaked here:

https://github.com/edsrzf/mmap-go/blob/904c4ced31cdffe19e971afa0b3d319ff06d9c72/mmap_windows.go#L68-L70