Documentation
¶
Overview ¶
Package memstats helps you monitor a running server's memory usage, visualize Garbage Collector information, run stack traces and memory profiles. To run the server, place this command at the top of your application:
go memstats.Serve()
The next time you run your application, profiling is available via websockets on port 6061, and once a client is connected it will send updates every 2 seconds. Defaults can be changed by passing one or more of the APIs options as params to Serve. See the examples for each option.
To use the provided webserver, run the command "memstat" once your applications starts and has profiling enabled. To change HTTP port or connected to other sockets than default, see:
memstats --help
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListenAddr ¶
func ListenAddr(addr string) func(*server)
ListenAddr sets the address that the server will listen on for HTTP and WebSockets connections. ListenAddr is one of the options that can be provided to Serve.
Example ¶
package main import ( "github.com/gbbr/memstats" ) func main() { // Start a goroutine that runs the memstat // server at the passed in address. go memstats.Serve(memstats.ListenAddr(":7777")) }
Output:
func Serve ¶
func Serve(opts ...func(*server))
Serve starts a memory monitoring server. By default it listens on :6061
Example ¶
package main import ( "github.com/gbbr/memstats" ) func main() { // Place this line at the top of your application to // start a live web visualization of memory profiling. go memstats.Serve() }
Output:
func Tick ¶
Tick sets the frequency at which the websockets will send updates. Tick is one of the options that can be provided to Serve.
Example ¶
package main import ( "time" "github.com/gbbr/memstats" ) func main() { // Starts a server on default port :6061 that // refreshes every minute. go memstats.Serve(memstats.Tick(time.Minute)) }
Output:
Types ¶
This section is empty.