mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-16 02:18:28 -07:00
ff23d7b6d7
* CI revamped and other enhancements GoReleaser for multi-arch binaries Switch to GitHub Actions (more versatile) with 2 workflows Docker multi-manifest image with buildx Fix eslint run script Go sum fixer Use tools.go paradigm for external dependencies (packr) Use go generate for packr * Update workflows * Add Slack notification * Rebase * Enhanced Dockerfile * Fix go generate * Fix Golangci lint * Fix npm cache with v2 cache action * Fix Dockerfile * Trigger notif * Issue with packr * s390x platform not supported by packr * Enhance layers * Fix go modules Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
53 lines
1.2 KiB
Go
53 lines
1.2 KiB
Go
//go:generate go install -v github.com/gobuffalo/packr/packr
|
|
//go:generate packr clean
|
|
//go:generate packr -z
|
|
package main
|
|
|
|
import (
|
|
"os"
|
|
"runtime/debug"
|
|
"time"
|
|
|
|
"github.com/AdguardTeam/AdGuardHome/home"
|
|
)
|
|
|
|
// version will be set through ldflags, contains current version
|
|
var version = "undefined"
|
|
|
|
// channel can be set via ldflags
|
|
var channel = "release"
|
|
|
|
// GOARM value - set via ldflags
|
|
var goarm = ""
|
|
|
|
func main() {
|
|
memoryUsage()
|
|
|
|
home.Main(version, channel, goarm)
|
|
}
|
|
|
|
// memoryUsage implements a couple of not really beautiful hacks which purpose is to
|
|
// make OS reclaim the memory freed by AdGuard Home as soon as possible.
|
|
func memoryUsage() {
|
|
debug.SetGCPercent(10)
|
|
|
|
// madvdontneed: setting madvdontneed=1 will use MADV_DONTNEED
|
|
// instead of MADV_FREE on Linux when returning memory to the
|
|
// kernel. This is less efficient, but causes RSS numbers to drop
|
|
// more quickly.
|
|
_ = os.Setenv("GODEBUG", "madvdontneed=1")
|
|
|
|
// periodically call "debug.FreeOSMemory" so
|
|
// that the OS could reclaim the free memory
|
|
go func() {
|
|
ticker := time.NewTicker(15 * time.Second)
|
|
for {
|
|
select {
|
|
case t := <-ticker.C:
|
|
t.Second()
|
|
debug.FreeOSMemory()
|
|
}
|
|
}
|
|
}()
|
|
}
|