"net/http"
"os"
"runtime"
+ "runtime/debug"
"sync"
_ "net/http/pprof" // Required to use pprof
os.Exit(0)
}
reportMemoryUsage("after parsing trace")
+ debug.FreeOSMemory()
log.Print("Splitting trace...")
ranges = splitTrace(res)
reportMemoryUsage("after spliting trace")
+ debug.FreeOSMemory()
addr := "http://" + ln.Addr().String()
log.Printf("Opening browser. Trace viewer is listening on %s", addr)
"net/http"
"path/filepath"
"runtime"
+ "runtime/debug"
"strconv"
"strings"
"time"
// httpJsonTrace serves json trace, requested from within templTrace HTML.
func httpJsonTrace(w http.ResponseWriter, r *http.Request) {
+ defer debug.FreeOSMemory()
defer reportMemoryUsage("after httpJsonTrace")
// This is an AJAX handler, so instead of http.Error we use log.Printf to log errors.
res, err := parseTrace()
// so flush can include them in the required
// part of the trace.
data.Events = append(data.Events, v)
+ return
}
enc := json.NewEncoder(&cw)
enc.Encode(v)
io.WriteString(w, ",")
}
enc.Encode(v)
+ // TODO: get rid of the extra \n inserted by enc.Encode.
+ // Same should be applied to splittingTraceConsumer.
written++
},
consumeViewerFrame: func(k string, v ViewerFrame) {