4 ms·
How does Go allow you to manage memory manually? Malloc/free or something more sophisticated?
by marrs 7y ago
How does Go allow you to manage memory manually? Malloc/free or something more sophisticated?
- tsimionescu 7y agoIt doesn't. You could start and stop the GC occasionally, maybe?
- masklinn 7y agoIt 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())
- lostcolony 7y agoSo 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.