Merge pull request #38 from monnand/memleak

fix the memory leak problem mentioned in #26
This commit is contained in:
Victor Marmol 2014-06-13 11:18:43 -07:00
commit e0518220a0
2 changed files with 8 additions and 5 deletions

View File

@ -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",

View File

@ -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()