mirror of
https://github.com/foomo/contentserver.git
synced 2025-10-16 12:25:44 +00:00
fixed loops for mem profiling
This commit is contained in:
parent
1449d6902c
commit
eca5e3b4f0
@ -74,9 +74,12 @@ func main() {
|
|||||||
if *flagFreeOSMem > 0 {
|
if *flagFreeOSMem > 0 {
|
||||||
log.Notice("[INFO] freeing OS memory every ", *flagFreeOSMem, " minutes!")
|
log.Notice("[INFO] freeing OS memory every ", *flagFreeOSMem, " minutes!")
|
||||||
go func() {
|
go func() {
|
||||||
for _ = range time.After(time.Duration(*flagFreeOSMem) * time.Minute) {
|
for {
|
||||||
log.Notice("FreeOSMemory")
|
select {
|
||||||
debug.FreeOSMemory()
|
case <-time.After(time.Duration(*flagFreeOSMem) * time.Second):
|
||||||
|
log.Notice("FreeOSMemory")
|
||||||
|
debug.FreeOSMemory()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
@ -84,16 +87,19 @@ func main() {
|
|||||||
if *flagHeapDump > 0 {
|
if *flagHeapDump > 0 {
|
||||||
log.Notice("[INFO] dumping heap every ", *flagHeapDump, " minutes!")
|
log.Notice("[INFO] dumping heap every ", *flagHeapDump, " minutes!")
|
||||||
go func() {
|
go func() {
|
||||||
for _ = range time.After(time.Duration(*flagFreeOSMem) * time.Minute) {
|
for {
|
||||||
log.Notice("HeapDump")
|
select {
|
||||||
f, err := os.Create("heapdump")
|
case <-time.After(time.Duration(*flagFreeOSMem) * time.Minute):
|
||||||
if err != nil {
|
log.Notice("HeapDump")
|
||||||
panic("failed to create heap dump file")
|
f, err := os.Create("heapdump")
|
||||||
}
|
if err != nil {
|
||||||
debug.WriteHeapDump(f.Fd())
|
panic("failed to create heap dump file")
|
||||||
err = f.Close()
|
}
|
||||||
if err != nil {
|
debug.WriteHeapDump(f.Fd())
|
||||||
panic("failed to create heap dump file")
|
err = f.Close()
|
||||||
|
if err != nil {
|
||||||
|
panic("failed to create heap dump file")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user