MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / getTotalMemory

Function getTotalMemory

rest/server_context.go:2295–2307  ·  view source on GitHub ↗

getTotalMemory returns the total memory available on the system. If a cgroup is detected, it will use the cgroup memory max.

(ctx context.Context)

Source from the content-addressed store, hash-verified

2293
2294// getTotalMemory returns the total memory available on the system. If a cgroup is detected, it will use the cgroup memory max.
2295func getTotalMemory(ctx context.Context) uint64 {
2296 memoryTotal, err := memlimit.FromCgroup()
2297 if err == nil {
2298 return memoryTotal
2299 }
2300 base.TracefCtx(ctx, base.KeyAll, "Did not detect a cgroup for a memory limit")
2301 memory, err := mem.VirtualMemory()
2302 if err != nil {
2303 base.WarnfCtx(ctx, "Error getting total memory from gopsutil: %v", err)
2304 return 0
2305 }
2306 return memory.Total
2307}
2308
2309// getClusterUUID returns the cluster UUID. rosmar does not have a ClusterUUID, so this will return an empty cluster UUID and no error in this case.
2310func (sc *ServerContext) getClusterUUID(ctx context.Context) (string, error) {

Callers 2

NewServerContextFunction · 0.85

Calls 2

TracefCtxFunction · 0.92
WarnfCtxFunction · 0.92

Tested by 1