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() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
// XXX(dengnan): Should we allow users to specify which sampler they want to use?
|
// XXX(dengnan): Should we allow users to specify which sampler they want to use?
|
||||||
container.SetStatsParameter(&container.StatsParameter{
|
container.SetStatsParameter(&container.StatsParameter{
|
||||||
Sampler: "uniform",
|
Sampler: "uniform",
|
||||||
|
@ -37,9 +37,9 @@ type containerStat struct {
|
|||||||
type containerInfo struct {
|
type containerInfo struct {
|
||||||
info.ContainerReference
|
info.ContainerReference
|
||||||
Subcontainers []info.ContainerReference
|
Subcontainers []info.ContainerReference
|
||||||
Spec *info.ContainerSpec
|
Spec *info.ContainerSpec
|
||||||
Stats *list.List
|
Stats *list.List
|
||||||
StatsSummary *info.ContainerStatsPercentiles
|
StatsSummary *info.ContainerStatsPercentiles
|
||||||
}
|
}
|
||||||
|
|
||||||
type containerData struct {
|
type containerData struct {
|
||||||
@ -100,12 +100,14 @@ func NewContainerData(containerName string) (*containerData, error) {
|
|||||||
|
|
||||||
func (c *containerData) housekeeping() {
|
func (c *containerData) housekeeping() {
|
||||||
// Housekeep every second.
|
// Housekeep every second.
|
||||||
for true {
|
ticker := time.NewTicker(1 * time.Second)
|
||||||
|
defer ticker.Stop()
|
||||||
|
for {
|
||||||
select {
|
select {
|
||||||
case <-c.stop:
|
case <-c.stop:
|
||||||
// Stop housekeeping when signaled.
|
// Stop housekeeping when signaled.
|
||||||
return
|
return
|
||||||
case <-time.Tick(time.Second):
|
case <-ticker.C:
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
c.housekeepingTick()
|
c.housekeepingTick()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user