fix the memory leak problem mentioned in #26
This commit is contained in:
parent
215627d408
commit
fa0f3efab7
@ -36,6 +36,7 @@ var argResetPeriod = flag.Duration("reset_period", 2*time.Hour, "period to reset
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
// XXX(dengnan): Should we allow users to specify which sampler they want to use?
|
||||
container.SetStatsParameter(&container.StatsParameter{
|
||||
Sampler: "uniform",
|
||||
|
@ -37,9 +37,9 @@ type containerStat struct {
|
||||
type containerInfo struct {
|
||||
info.ContainerReference
|
||||
Subcontainers []info.ContainerReference
|
||||
Spec *info.ContainerSpec
|
||||
Stats *list.List
|
||||
StatsSummary *info.ContainerStatsPercentiles
|
||||
Spec *info.ContainerSpec
|
||||
Stats *list.List
|
||||
StatsSummary *info.ContainerStatsPercentiles
|
||||
}
|
||||
|
||||
type containerData struct {
|
||||
@ -100,12 +100,14 @@ func NewContainerData(containerName string) (*containerData, error) {
|
||||
|
||||
func (c *containerData) housekeeping() {
|
||||
// Housekeep every second.
|
||||
for true {
|
||||
ticker := time.NewTicker(1 * time.Second)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-c.stop:
|
||||
// Stop housekeeping when signaled.
|
||||
return
|
||||
case <-time.Tick(time.Second):
|
||||
case <-ticker.C:
|
||||
start := time.Now()
|
||||
c.housekeepingTick()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user