MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / forceGC

Function forceGC

tensorflow/go/operation_test.go:254–269  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

252}
253
254func forceGC() {
255 var mem runtime.MemStats
256 runtime.ReadMemStats(&mem)
257 // It was empirically observed that without this extra allocation
258 // TestOperationLifetime would fail only 50% of the time if
259 // Operation did not hold on to a reference to Graph. With this
260 // additional allocation, and with the bug where Operation does
261 // not hold onto a Graph, the test failed 90+% of the time.
262 //
263 // The author is aware that this technique is potentially fragile
264 // and fishy. Suggestions for alternatives are welcome.
265 bytesTillGC := mem.NextGC - mem.HeapAlloc + 1
266 _ = make([]byte, bytesTillGC)
267 runtime.GC()
268 debug.FreeOSMemory()
269}

Callers 1

TestOperationLifetimeFunction · 0.85

Calls 2

makeFunction · 0.85
GCMethod · 0.80

Tested by

no test coverage detected