This should only be used as a temporary workaround to diagnose buggy code.
The real fix is to not store integers in pointer-typed locations.
+ memprofrate: setting memprofrate=X will update the value of runtime.MemProfileRate.
+ When set to 0 memory profiling is disabled. Refer to the description of
+ MemProfileRate for the default value.
+
scheddetail: setting schedtrace=X and scheddetail=1 causes the scheduler to emit
detailed multiline info every X milliseconds, describing state of the scheduler,
processors, threads and goroutines.
// TODO(rsc): Make GC respect debug.invalidptr.
-// Holds variables parsed from GODEBUG env var.
+// Holds variables parsed from GODEBUG env var,
+// except for "memprofrate" since there is an
+// existing int var for that value, which may
+// already have an initial value.
var debug struct {
allocfreetrace int32
efence int32
continue
}
key, value := field[:i], field[i+1:]
- for _, v := range dbgvars {
- if v.name == key {
- *v.value = int32(atoi(value))
+
+ // Update MemProfileRate directly here since it
+ // int, not int32, and should only be updated
+ // if specified in GODEBUG.
+ if key == "memprofrate" {
+ MemProfileRate = atoi(value)
+ } else {
+ for _, v := range dbgvars {
+ if v.name == key {
+ *v.value = int32(atoi(value))
+ }
}
}
}