github.com/fjl/memsize@v0.0.2/README (about) 1 For Go API documentation, go to https://pkg.go.dev/github.com/fjl/memsize 2 3 --- 4 5 Package memsize computes the size of your object graph. 6 7 For any Go object, it can compute the amount of memory referenced by the object. 8 Almost all Go types are supported, except for function pointers. 9 10 To scan a value and print the amount of memory it uses, run 11 12 sizes := memsize.Scan(myValue) 13 fmt.Println(sizes.Total) 14 15 If your program provides an HTTP server for debugging (e.g. using net/http/pprof), 16 you can also add an interactive memsize tool there and use it from a 17 web browser. To do this, add 18 19 import "github.com/fjl/memsize/memsizeui" 20 21 var memsizeH memsizeui.Handler 22 23 and then hook the handler up to your debugging HTTP server. The web 24 interface will display buttons for added 'roots', which you must register 25 on the handler: 26 27 memsizeH.Add("myObject", &myObject)