Skip to content
forked from golang/go

Commit

Permalink
Merge pull request #171 from golang/master
Browse files Browse the repository at this point in the history
doc/articles/race_detector: mention memory leak potential
  • Loading branch information
sthagen authored Feb 25, 2020
2 parents 002a957 + ba093c4 commit 5a20382
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions doc/articles/race_detector.html
Original file line number Diff line number Diff line change
Expand Up @@ -395,3 +395,14 @@ <h2 id="Runtime_Overheads">Runtime Overhead</h2>
The cost of race detection varies by program, but for a typical program, memory
usage may increase by 5-10x and execution time by 2-20x.
</p>

<p>
The race detector currently allocates an extra 8 bytes per <code>defer</code>
and <code>recover</code> statement. Those extra allocations <a
href="https://golang.org/issue/26813">are not recovered until the goroutine
exits</a>. This means that if you have a long-running goroutine that is
periodically issuing <code>defer</code> and <code>recover</code> calls,
the program memory usage may grow without bound. These memory allocations
will not show up in the output of <code>runtime.ReadMemStats</code> or
<code>runtime/pprof</code>.
</p>

0 comments on commit 5a20382

Please sign in to comment.