If you are running Go on an embedded device or a device with very constrained memory, it's sometimes smart to understand some of the underlying processes within the runtime to make informed decisions regarding your processes. The Go garbage collector prioritizes low latency and simplicity. It uses a non-generational concurrent tri-color mark and sweep garbage collector. By default, it manages memory allocation automatically.
Go has a function in the debug standard library that will force a garbage collection and return memory to the OS. The Go garbage collector returns unused memory to the OS after 5 minutes. If you are running on a low memory device, this function, FreeOSMemory(), can be found here: https://golang.org/pkg/runtime/debug/#FreeOSMemory.
We can also use the GC() function, which can be found here: https://golang.org/pkg/runtime...