StartMemProfile starts the memory profiling rate that controls the fraction of memory allocations that are recorded and reported in the memory profile.
(rate int, file string)
| 180 | // StartMemProfile starts the memory profiling rate that controls the fraction of memory allocations |
| 181 | // that are recorded and reported in the memory profile. |
| 182 | func (h *HandlerT) StartMemProfile(rate int, file string) error { |
| 183 | h.mu.Lock() |
| 184 | defer h.mu.Unlock() |
| 185 | |
| 186 | if h.memW != nil { |
| 187 | return errors.New("Memory heap profiling already in progress") |
| 188 | } |
| 189 | f, err := os.Create(file) |
| 190 | if err != nil { |
| 191 | return err |
| 192 | } |
| 193 | h.memFile = file |
| 194 | h.memW = f |
| 195 | |
| 196 | runtime.MemProfileRate = rate |
| 197 | return nil |
| 198 | } |
| 199 | |
| 200 | // StopMemHeapProfile stops an ongoing memory heap profile |
| 201 | func (h *HandlerT) StopMemHeapProfile() error { |