Просмотр исходного кода

Reclaim memory between processing each OSL

Rod Hynes 8 лет назад
Родитель
Сommit
f8bf40d34a
2 измененных файлов с 10 добавлено и 0 удалено
  1. 6 0
      psiphon/remoteServerList.go
  2. 4 0
      psiphon/utils.go

+ 6 - 0
psiphon/remoteServerList.go

@@ -282,6 +282,12 @@ func FetchObfuscatedServerLists(
 		}
 
 		file.Close()
+
+		// Clear the reference to this OSL file streamer and immediately run
+		// a garbage collection to reclaim its memory before processing the
+		// next file.
+		serverListPayloadReader = nil
+		defaultGarbageCollection()
 	}
 
 	// Now that a new registry is downloaded, validated, and parsed, store

+ 4 - 0
psiphon/utils.go

@@ -223,3 +223,7 @@ func standardGarbageCollection() {
 	debug.SetGCPercent(100)
 	debug.FreeOSMemory()
 }
+
+func defaultdGarbageCollection() {
+	debug.FreeOSMemory()
+}