mirror of
https://github.com/pgsty/minio.git
synced 2026-08-10 08:13:28 +03:00
Object-cache: enforce cache size to be less than RAM. (#2338)
This commit is contained in:
committed by
Harshavardhana
parent
1494af485e
commit
69fd196471
+16
-1
@@ -18,7 +18,11 @@
|
||||
|
||||
package main
|
||||
|
||||
import "syscall"
|
||||
import (
|
||||
"syscall"
|
||||
|
||||
"github.com/minio/minio/pkg/sys"
|
||||
)
|
||||
|
||||
// For all unixes we need to bump allowed number of open files to a
|
||||
// higher value than its usual default of '1024'. The reasoning is
|
||||
@@ -72,5 +76,16 @@ func setMaxMemory() error {
|
||||
if rLimit.Cur < globalMaxCacheSize {
|
||||
globalMaxCacheSize = (80 / 100) * rLimit.Cur
|
||||
}
|
||||
|
||||
// Make sure globalMaxCacheSize is less than RAM size.
|
||||
stats, err := sys.GetStats()
|
||||
if err != nil && err != sys.ErrNotImplemented {
|
||||
// sys.GetStats() is implemented only on linux. Ignore errors
|
||||
// from other OSes.
|
||||
return err
|
||||
}
|
||||
if err == nil && stats.TotalRAM < globalMaxCacheSize {
|
||||
globalMaxCacheSize = (80 / 100) * stats.TotalRAM
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user