I'm studying Process Memory model and got curious with JavaScript's memory model.
Process Memory model is divided in 5 sections. Code, Data, BSS, Heap, Stack.
I got two questions while studying on it.
First, when javascript get compiled(Just-In-Time compilation), and the process is on cpu and finally it will have those 5 sections of the process. What does BSS do from the sections? BSS is for the global variables with only declaration and not assigned one. Then in the javascript file, if there's some variable without value but declared globally, does it save in BSS? Or is there any other stuff saved in BSS?
Second, what I learned about javascript memory model is, local variables like const, let with primitive dataset is saved in stack, and data types like object, array is saved in heap. What I imagined is, compiled code(from JIT compilation) is saved in code section. Then when we use console of chrome, and create function, where does it save?
I can feel something goes wrong on my mind, and something is wrong, so I want to make it clear but couldn't find answer on it.
So TL;DR:
- What does process memory model's BSS section save when JavaScript process comes?
- When we create function from console of chrome devtool, does it save in stack memory?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…