SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
avoid possible too big memory allocation
chrislu708e14fcfa71
diff --git a/weed/util/mem/slot_pool.go b/weed/util/mem/slot_pool.goindex 5bd759ab7a..f7aa86e058 100644--- a/weed/util/mem/slot_pool.go+++ b/weed/util/mem/slot_pool.go@@ -41,14 +41,23 @@ func getSlotPool(size int) *sync.Pool {var total int64func Allocate(size int) []byte {- newVal := atomic.AddInt64(&total, 1)- glog.V(4).Infof("++> %d", newVal)- slab := *getSlotPool(size).Get().(*[]byte)- return slab[:size]+ pool := getSlotPool(size)+ if pool != nil {++ newVal := atomic.AddInt64(&total, 1)+ glog.V(4).Infof("++> %d", newVal)++ slab := *pool.Get().(*[]byte)+ return slab[:size]+ }+ return make([]byte, size)}func Free(buf []byte) {- newVal := atomic.AddInt64(&total, -1)- glog.V(4).Infof("--> %d", newVal)- getSlotPool(cap(buf)).Put(&buf)+ pool := getSlotPool(cap(buf))+ if pool != nil {+ newVal := atomic.AddInt64(&total, -1)+ glog.V(4).Infof("--> %d", newVal)+ pool.Put(&buf)+ }}