mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-02 14:35:39 +00:00
dc02d49bf1
This allows C2N clients to obtain sampled information about memory allocations since the program started. We now also force GC on logheap. Updates tailscale/corp#18514 Signed-off-by: Percy Wegmann <percy@tailscale.com>
22 lines
381 B
Go
22 lines
381 B
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
//go:build !js && !wasm
|
|
|
|
package ipnlocal
|
|
|
|
import (
|
|
"net/http"
|
|
"runtime/pprof"
|
|
)
|
|
|
|
func init() {
|
|
c2nLogHeap = func(w http.ResponseWriter, r *http.Request) {
|
|
pprof.WriteHeapProfile(w)
|
|
}
|
|
|
|
c2nLogAllocs = func(w http.ResponseWriter, r *http.Request) {
|
|
pprof.Lookup("allocs").WriteTo(w, 0)
|
|
}
|
|
}
|