dustin norlander <
dus...@trendrr.com> writes:
> On 06/26/2012 06:39 AM, Ian Lance Taylor wrote:
>> Faissal Graviton <
amr.f...@gmail.com> writes:
>>
>>> can i disable the garbage collector in Go in order to gain more speed?
>> Set the environment variable GOGC to "off".
>>
>> GOGC=off go run program
>>
>> Ian
>
> This is interesting.. Though, afaik there is no way to explicitly
> free allocated objects (thus turning off gc would be of limited
> usefulness). Am I wrong?
You are correct.
Even if there were an explicit free function, Go programs routinely
allocate memory implicitly. Tracking that memory would be quite
difficult, and any attempt to free it would require the use of the
unsafe package.
Disabling the garbage collector is only of interest for testing
purposes, or possibly for programs that only run for a short time.
Ian