fjl / memsize

memsize computes the size of your object graph

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

For Go API documentation, go to https://pkg.go.dev/github.com/fjl/memsize

---

Package memsize computes the size of your object graph.

For any Go object, it can compute the amount of memory referenced by the object.
Almost all Go types are supported, except for function pointers.

To scan a value and print the amount of memory it uses, run

    sizes := memsize.Scan(myValue)
    fmt.Println(sizes.Total)

If your program provides an HTTP server for debugging (e.g. using net/http/pprof),
you can also add an interactive memsize tool there and use it from a
web browser. To do this, add

    import "github.com/fjl/memsize/memsizeui"

    var memsizeH memsizeui.Handler

and then hook the handler up to your debugging HTTP server. The web
interface will display buttons for added 'roots', which you must register
on the handler:

    memsizeH.Add("myObject", &myObject)

About

memsize computes the size of your object graph

License:MIT License


Languages

Language:Go 99.8%Language:Assembly 0.2%