Open
Description
The sysctl implementation allocates 256 KiB for every invocation.
In go-sysinfo a sync.Pool is used to minimize the amount of memory that is allocated for each call. It uses a buffer from the pool to make the call then allocates only the size required rather than ARG_MAX.
Port this same optimization to the system metrics package. Here is one example where it would apply:
elastic-agent-system-metrics/metric/system/process/process_darwin.go
Lines 154 to 161 in 5f48574
We could avoid allocating a new slice for every process with this optimization.