diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-03-16 00:00:12 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-03-15 08:04:14 -0700 |
commit | 4821c2af8f120d312dc9e6b95b5dd7bd663f35d4 (patch) | |
tree | 13d4f595de059e6117d70ba8f6217b5bf2e82852 | |
parent | 77f0e6acf15716776eaf11d81a7b730cac73352a (diff) |
gobgpd: support force GC and return free memory to OS
Sending signal USR1 to run GC and return free memory to OS. It's for
debugging memory leak.
Maybe we could support this feature via the GRPC API.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | gobgpd/main.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gobgpd/main.go b/gobgpd/main.go index 05c20555..15ad1a56 100644 --- a/gobgpd/main.go +++ b/gobgpd/main.go @@ -30,13 +30,14 @@ import ( "os" "os/signal" "runtime" + "runtime/debug" "strings" "syscall" ) func main() { sigCh := make(chan os.Signal, 1) - signal.Notify(sigCh, syscall.SIGHUP, syscall.SIGTERM) + signal.Notify(sigCh, syscall.SIGHUP, syscall.SIGTERM, syscall.SIGUSR1) var opts struct { ConfigFile string `short:"f" long:"config-file" description:"specifying a config file"` @@ -260,6 +261,9 @@ func main() { reloadCh <- true case syscall.SIGKILL, syscall.SIGTERM: bgpServer.Shutdown() + case syscall.SIGUSR1: + runtime.GC() + debug.FreeOSMemory() } } } |