Hacker News new | ask | show | jobs
by marrs 2326 days ago
How does Go allow you to manage memory manually? Malloc/free or something more sophisticated?
3 comments

It doesn't. If you disable the GC… you only have an allocator, the only "free" is to run the entire GC by hand (calling runtime.GC())
So other comments didn't mention this, per se, but Go gives you tools to see what memory escapes the stack and ends up being heap allocated. If you work to ensure things stay stack allocated, it gets freed when the stack frees, and the GC never touches it.

But, per other comments, there isn't any direct malloc/free behavior. It just provides tools to help you enable the compiler to determine that GC is not needed for some.

It doesn't. You could start and stop the GC occasionally, maybe?