Skip to content
This repository was archived by the owner on May 6, 2024. It is now read-only.

Commit 1d8e9b8

Browse files
authored
Android: increase garbage collection frequency (#11)
1 parent 2428801 commit 1d8e9b8

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

android/common.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@ import (
1818
"errors"
1919
"log"
2020
"os"
21+
"runtime/debug"
2122

2223
"github.com/Jigsaw-Code/outline-go-tun2socks/tunnel"
2324
)
2425

2526
const vpnMtu = 1500
2627

28+
func init() {
29+
// Conserve memory by increasing garbage collection frequency.
30+
debug.SetGCPercent(10)
31+
}
32+
2733
func makeTunFile(fd int) (*os.File, error) {
2834
if fd < 0 {
2935
return nil, errors.New("Must provide a valid TUN file descriptor")

tunnel/outline.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (t *outlinetunnel) SetUDPEnabled(isUDPEnabled bool) {
6262
return
6363
}
6464
t.isUDPEnabled = isUDPEnabled
65-
t.lwipStack.Close() // Close exisiting connections to avoid using the previous handlers.
65+
t.lwipStack.Close() // Close existing connections to avoid using the previous handlers.
6666
t.registerConnectionHandlers()
6767
}
6868

0 commit comments

Comments
 (0)