Package memory provides two methods reporting total physical system memory
accessible to the kernel, and free memory available to the running application.
This package has no external dependency besides the standard library and default operating system tools.
This is useful for dynamic code to minimize thrashing and other contention, similar to the stdlib runtime.NumCPU
See some history of the proposal at https://github.com/golang/go/issues/21816
fmt.Printf("Total system memory: %d\n", memory.TotalMemory())
fmt.Printf("Free memory: %d\n", memory.FreeMemory())
Tested/working on:
Tested on virtual machines:
If you have access to untested systems please test and report success/bugs.
409 followers · starred Dec 2018
2,510 followers · starred Jun 2020
194 followers · starred Jun 2023
1,215 followers · starred Sep 2023
Package memory provides two methods reporting total physical system memory
accessible to the kernel, and free memory available to the running application.
This package has no external dependency besides the standard library and default operating system tools.
This is useful for dynamic code to minimize thrashing and other contention, similar to the stdlib runtime.NumCPU
See some history of the proposal at https://github.com/golang/go/issues/21816
fmt.Printf("Total system memory: %d\n", memory.TotalMemory())
fmt.Printf("Free memory: %d\n", memory.FreeMemory())
Tested/working on:
Tested on virtual machines:
If you have access to untested systems please test and report success/bugs.
409 followers · starred Dec 2018
2,510 followers · starred Jun 2020
194 followers · starred Jun 2023
1,215 followers · starred Sep 2023