runtime: read-only accessor for gcpercent #39419
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
FeatureRequest
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
I would like to programmatically access the current value of
GOGC
in my program (for logging it, with various runtime stats).For
GOMAXPROCS
, I can callruntime.GOMAXPROCS(0)
to get the current value without changing it. However, forGOGC
, I see no way of reading the value without writing. I could do a two-step call likebut I am worried about the disruption that this may cause in a program that is under load and that has a non-standard
GOGC
value in the first place.The documentation for SetGCPercent says that a negative value will disable GC, however there is no documented effect for calling it with 0. Maybe this could be defined to just return the current value, like in GOMAXPROCS? This would just be a matter of making
runtime.setGCPercent
return early in this case.The text was updated successfully, but these errors were encountered: