Let’s look at how two popular programming languages Rust and Go manage memory.

When a program starts, it creates a process with its own address space and threads running on CPU cores. The processor operates on virtual memory - an abstraction managed by the operating system.

For example, in Go, when we create an array:

arr := make([]byte, 100)

The runtime requests a range of virtual addresses, but the physical memory is not allocated immediately; it is allocated only when the data is accessed for the first time.

first := arr[0]

When the first element is accessed, a page fault occurs, and the operating system allocates a physical page, usually 4 KB in size, linking it to the virtual address range.

Stack and heap

Each process has a shared memory …

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help