mirror of
https://github.com/diamondburned/cchat-gtk.git
synced 2025-11-30 08:27:16 +00:00
Added aggressive GC with GODEBUG=madvdontneed=1
This commit is contained in:
parent
35c186580b
commit
ebc8e82907
18
main.go
18
main.go
|
|
@ -1,6 +1,11 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
"runtime/debug"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/diamondburned/cchat-gtk/internal/gts"
|
"github.com/diamondburned/cchat-gtk/internal/gts"
|
||||||
"github.com/diamondburned/cchat-gtk/internal/log"
|
"github.com/diamondburned/cchat-gtk/internal/log"
|
||||||
"github.com/diamondburned/cchat-gtk/internal/ui"
|
"github.com/diamondburned/cchat-gtk/internal/ui"
|
||||||
|
|
@ -14,6 +19,19 @@ import (
|
||||||
// destructor is used for debugging and profiling.
|
// destructor is used for debugging and profiling.
|
||||||
var destructor = func() {}
|
var destructor = func() {}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// Aggressive memory freeing you asked, so aggressive memory freeing we will
|
||||||
|
// deliver.
|
||||||
|
if strings.Contains(os.Getenv("GODEBUG"), "madvdontneed=1") {
|
||||||
|
go func() {
|
||||||
|
log.Println("Now attempting to free memory every 5s... (madvdontneed=1)")
|
||||||
|
for range time.Tick(5 * time.Second) {
|
||||||
|
debug.FreeOSMemory()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
gts.Main(func() gts.MainApplication {
|
gts.Main(func() gts.MainApplication {
|
||||||
var app = ui.NewApplication()
|
var app = ui.NewApplication()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue