Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Server Memory - BuildStuff Ukraine 2019
Search
Андрей Листочкин (Andrey Listochkin)
November 18, 2019
Programming
77
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Server Memory - BuildStuff Ukraine 2019
Андрей Листочкин (Andrey Listochkin)
November 18, 2019
More Decks by Андрей Листочкин (Andrey Listochkin)
See All by Андрей Листочкин (Andrey Listochkin)
Everybody Stand Back! I Know Regular Expressions
listochkin
0
250
Command-line scripting with Rust. Wait, what?!
listochkin
0
430
Server Memory - Chernivtsi JS 2019
listochkin
1
170
10 Years Later
listochkin
0
400
Managing Managers - DevTalks iHUB
listochkin
0
89
Time, Numbers, Text
listochkin
1
680
Software Licensing: A Minefield Guide
listochkin
0
190
We Make Bots. For Real
listochkin
0
480
Devops for A Busy Developer - XP Days 2016
listochkin
0
200
Other Decks in Programming
See All in Programming
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
220
LLM 101
dalinaum
0
450
学びを記事・スライド・Xへ高速展開する― AI-assisted Learning Loopで回すコンテンツ生成術
ochtum
0
190
Event is what happens
moro
2
3.1k
graphql-ruby を Spinel で速くしようとした話
mtsmfm
0
140
Lambda durable functionsでHuman in the Loopを楽に…楽に……
har1101
2
250
Web3Dライブラリを作ってVue Custom Rendererの仕組みを理解しよう / lets learn vue custom renderer by making 3d library
drumath2237
1
120
AI時代のTerminal環境を UNIX哲学で設計・運用する
yasunori0418
1
340
Next.js: The final boss of Web Performance
guaca
0
380
AIがコードを書いてくれる時代、我々は何を確かめるのか
yosuke_furukawa
PRO
13
5.6k
TS 7.0 で baseUrl が使えなくなった今、パスエイリアスをどうするか
bicstone
2
450
Apple Intelligenceとオンデバイス時代の到来
yahir0
0
190
Featured
See All Featured
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
What does AI have to do with Human Rights?
axbom
PRO
1
2.5k
Designing for humans not robots
tammielis
254
26k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.5k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
2
430
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
5
880
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
2
970
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
610
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.3k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
550
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.2k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
20k
Transcript
None
@listochkin + fb.com/tektonna
Memory Management
A bit deeper than most talks on similar subject
None
CPU Caches RAM Swap Disk Network
Operating System
None
Pages 4k
Virtual
3 processes [0 … ∞] [0 … ∞] [0 …
∞]
Allocate page But not really
None
malloc calloc realloc
None
pointer = malloc(size)
free(pointer)
malloc malloc malloc free malloc free free
Forget to free Free the wrong pointer Read from unallocated
memory
Can we do better?
Reference Counting
None
const players = [ … ] players.forEach(p => makeMove(p))
a = … doX(a) yield a
if ( … ) { let a = … …
}
C++: std::shared_ptr
None
Optimizations
Delayed Counting
Don’t count local references
function (user) { let email = user.email; … … }
Delayed deallocation
Reference Cycles
None
None
Compile time ref-counting
Several types of pointers
Ownership
Forbids cycles by forbidding several owning references at the same
time
None
None
None
Perl 1987 - today Python 1991 - 2001 PHP 1994
- 2009
Multiprocess deploys
fork
Copy on Write
Worker Accepts requests As memory use raises: Stop accepting requests
Complete in-flight requests Terminate
Master Keep track on workers Start new workers Signal them
to terminate when memory pressure is high
“Pre-fork”
Load the framework Load app code Run full GC ----
Start forking process to accept requests
None
None
“Processes” Supervision Trees
Tracing GC
1959 60 years ago
Start at Root references Follow all references Build a live
objects tree Delete all objects not part of the tree
Ruby Java JavaScript Lua Go Default Choice
Roots?
Constants Global variables Local variables Closures Thread-locals ...
Mark & Sweep vs Mark-Compact
None
Team Sweep: Go Ruby* Lua Embedded JS engines Erlang
Pros: Pointers don’t change Native extensions Easier to implement
Team Compact: Java JavaScript Ruby* Haskell
Pros: Less memory fragmentation over time Cons: Harder Takes longer
to do a GC
Incremental Marking
3-colored algorithm by Dijkstra™
None
None
None
None
None
What is a barrier? if statement
CPU branch predictor
Parallel marking
None
Lazy Sweep
Generational
Temporary data data.filter( … ).map( … ) log(`… ${data}`) JSON.stringify(result)
Major vs Minor GC
Pointers from Old objects to new objects
Remembered Set
Major GC Scan roots only Bigger object graph
Minor GC Scan roots + RS Small object graph
None
Modern GCs are hybrid
None
None
C-extensions
Can’t move objects if their references are passed to an
extension
Can’t add WB
RGen GC
2 types of objects WB-protected WB-unprotected
WBu are never OldGen
OldGen -> WBu WBu to Remembered Set
Mark WBus on every minor GC
Adding compaction for WBp
None
V8
Minor GC Parallel
Major Parallel marking Parallel / Concurrent Compact || Sweep
None
When to trigger GC?
Out-of-Bounds GC
Firefox Run GC in background tabs first instead of current
tab
Chrome Animation frame
OS Pages pre-forked processes malloc zones GC Regions Remembered Sets
Barriers
None
None
Practical Advice
Memory Leaks Multiprocess Deploys
Throughput ⇔ Latency
Throughput Batch jobs Queues
Latency Requests Messaging
Keep different types of workloads in different processes
More memory Swap with SSDs
Experiment and measure
@listochkin Hire Me!