Fix memory leak in server
Remove server instrumentation
This commit is contained in:
@@ -44,10 +44,32 @@ func handleDownload(responseWriter http.ResponseWriter, request *http.Request) {
|
||||
}
|
||||
|
||||
func init() {
|
||||
log.SetFlags(log.Lmicroseconds | log.Lshortfile)
|
||||
// log.SetFlags(log.Lmicroseconds | log.Lshortfile)
|
||||
log.SetFlags(log.Lmicroseconds)
|
||||
}
|
||||
|
||||
// Mainly used to detect memory leaks
|
||||
// func instrument() {
|
||||
// numGoroutines := runtime.NumGoroutine()
|
||||
|
||||
// var m runtime.MemStats
|
||||
// runtime.ReadMemStats(&m)
|
||||
|
||||
// malloc := float64(m.Alloc)
|
||||
// ramUsedMB := malloc / 1024 / 1024
|
||||
// kbPerGoroutine := malloc / 1024 / float64(numGoroutines)
|
||||
|
||||
// log.Printf("Number of active goroutines: %d; RAM used: %.2f MB; KB per goroutine: %.2f", numGoroutines, ramUsedMB, kbPerGoroutine)
|
||||
// }
|
||||
|
||||
func main() {
|
||||
// go func() {
|
||||
// for {
|
||||
// time.Sleep(1 * time.Second)
|
||||
// instrument()
|
||||
// }
|
||||
// }()
|
||||
|
||||
http.HandleFunc("/ws", wsHandler)
|
||||
http.HandleFunc("/download", handleDownload)
|
||||
log.Println("Server starting on :8080")
|
||||
|
Reference in New Issue
Block a user