1 parent 000e70e commit 98c1b0eCopy full SHA for 98c1b0e
1 file changed
mpt/internal/span/span_unix.go
@@ -63,7 +63,12 @@ func (s *Span) Release() error {
63
if err := unix.Mprotect(s.mem[:s.alloc], unix.PROT_NONE); err != nil {
64
return fmt.Errorf("span.Release: mprotect: %w", err)
65
}
66
- if err := unix.Madvise(s.mem[:s.alloc], unix.MADV_FREE); err != nil {
+ err := unix.Madvise(s.mem[:s.alloc], unix.MADV_FREE)
67
+ if err == unix.EINVAL {
68
+ // MADV_FREE is missing before Linux 4.5 and in gVisor.
69
+ err = unix.Madvise(s.mem[:s.alloc], unix.MADV_DONTNEED)
70
+ }
71
+ if err != nil {
72
return fmt.Errorf("span.Release: madvise: %w", err)
73
74
0 commit comments