

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: Learn Go
incomplete
2: Declaring a Variable
incomplete
3: Basic Variables
incomplete
4: Short Variable Declaration
incomplete
5: Why Go?
incomplete
6: Comments
incomplete
7: The Compilation Process
incomplete
8: Fast and Compiled
incomplete
9: Type Sizes
incomplete
10: Which Type Should I Use?
incomplete
11: Go Is Statically Typed
incomplete
12: Compiled vs. Interpreted
incomplete
13: Same Line Declarations
incomplete
14: Small Memory Footprint
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Go programs are fairly lightweight. Each program includes a small amount of extra code that's included in the executable binary called the Go Runtime. One of the purposes of the Go runtime is to clean up unused memory at runtime. It includes a garbage collector that automatically frees up memory that's no longer in use.
As a general rule, Java programs use more memory than comparable Go programs. There are several reasons for this, but one of them is that Java uses a virtual machine to interpret bytecode at runtime and typically allocates more on the heap.
On the other hand, Rust and C programs use slightly less memory than Go programs because more control is given to the developer to optimize the memory usage of the program. The Go runtime just handles it for us automatically.
In the chart above, Dexter Darwich compares the memory usage of three very simple programs written in Java, Go, and Rust. As you can see, Go and Rust use very little memory when compared to Java.
Click to play video