Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
137 views
in Technique[技术] by (71.8m points)

JavaScript Memory Model with Process Memory model

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:

  1. What does process memory model's BSS section save when JavaScript process comes?
  2. When we create function from console of chrome devtool, does it save in stack memory?

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...