Skip to content

Commit ba093c4

Browse files
committed
doc/articles/race_detector: mention memory leak potential
As far as I can tell, there is no public documentation on this topic, which cost me several days of debugging. I am possibly unusual in that I run binaries in production with the race detector turned on, but I think that others who do the same may want to be aware of the risk. Updates #26813. Updates #37233. Change-Id: I1f8111bd01d0000596e6057b7cb5ed017d5dc655 Reviewed-on: https://go-review.googlesource.com/c/go/+/220586 Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 490bc60 commit ba093c4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

doc/articles/race_detector.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,3 +395,14 @@ <h2 id="Runtime_Overheads">Runtime Overhead</h2>
395395
The cost of race detection varies by program, but for a typical program, memory
396396
usage may increase by 5-10x and execution time by 2-20x.
397397
</p>
398+
399+
<p>
400+
The race detector currently allocates an extra 8 bytes per <code>defer</code>
401+
and <code>recover</code> statement. Those extra allocations <a
402+
href="https://golang.org/issue/26813">are not recovered until the goroutine
403+
exits</a>. This means that if you have a long-running goroutine that is
404+
periodically issuing <code>defer</code> and <code>recover</code> calls,
405+
the program memory usage may grow without bound. These memory allocations
406+
will not show up in the output of <code>runtime.ReadMemStats</code> or
407+
<code>runtime/pprof</code>.
408+
</p>

0 commit comments

Comments
 (0)