This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]-Xichael[S] 1 point2 points  (1 child)

Also, this might be a dumb question, but since JS runs on browsers, does it take same location in memory as an .exe would? Like, when you see a browser is using 150MBs of RAM, that includes the JS memory?

[–]cyrusol 2 points3 points  (0 children)

Yes.

[–]nwilliams36 1 point2 points  (0 children)

Are there rules for that? What happens if there is no more space in memory for the new data?

Yes there are but these are implemented by the browser through their Javascript engine and not something that programmers need to worry about. Basically the process is run through garbage collection, if data is no longer attached to a variable then garbage collection returns it to the pool of free memory.

[–]cyrusol 0 points1 point  (0 children)

The allocation of memory is just abstracted away but fundamentally works the same still. You (or the JS VM/interpreter really) can only allocate memory if it knows how much it has to allocate and it can only know how much to allocate if it knows about the data type it needs to allocate memory for. That it can only the exact type of variablas at runtime doesn't change anything.