Git Product home page Git Product logo

memory's Introduction

memory

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.

Documentation: GoDoc

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 golang/go#21816

Example

fmt.Printf("Total system memory: %d\n", memory.TotalMemory())
fmt.Printf("Free memory: %d\n", memory.FreeMemory())

Testing

Tested/working on:

  • macOS 10.12.6 (16G29), 10.15.7 (19H2)
  • Windows 10 1511 (10586.1045)
  • Linux RHEL (3.10.0-327.3.1.el7.x86_64)
  • Raspberry Pi 3 (ARMv8) on Raspbian, ODROID-C1+ (ARMv7) on Ubuntu, C.H.I.P (ARMv7).
  • Amazon Linux 2 aarch64 (m6a.large, 4.14.203-156.332.amzn2.aarch64)

Tested on virtual machines:

  • Windows 7 SP1 386
  • Debian stretch 386
  • NetBSD 7.1 amd64 + 386
  • OpenBSD 6.1 amd64 + 386
  • FreeBSD 11.1 amd64 + 386
  • DragonFly BSD 4.8.1 amd64

If you have access to untested systems please test and report success/bugs.

memory's People

Contributors

maruel avatar pbnjay avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.