From 693606fa807c30ce4c0ce25e2fa852210533b19f Mon Sep 17 00:00:00 2001 From: Matthew Jaffee Date: Tue, 10 Aug 2021 14:01:53 -0500 Subject: [PATCH] better explanation for 'cannot allocate memory' error --- syswrap/mmap.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/syswrap/mmap.go b/syswrap/mmap.go index 238f6dd6f..2d89ce39b 100644 --- a/syswrap/mmap.go +++ b/syswrap/mmap.go @@ -20,6 +20,7 @@ import ( "sync" "sync/atomic" "syscall" + "strings" "github.com/pkg/errors" ) @@ -56,6 +57,9 @@ func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, e data, err = syscall.Mmap(fd, offset, length, prot, flags) if err != nil { atomic.AddUint64(&mapCount, ^uint64(0)) // decrement + if strings.Contains(err.Error(), "cannot allocate memory") { + err = errors.New("mmap 'cannot allocate memory' — please see the troubleshooting how-to in the FeatureBase docs.") + } } return data, err }