JavaScript Questions & Answers – Performance Navigation and Memory – II

This set of JavaScript Multiple Choice Questions & Answers (MCQs) focuses on “Performance Navigation and Memory – II”.

1. How many properties are available in a memory object?
a) 1
b) 2
c) 3
d) 4
View Answer

Answer: c
Explanation: Advanced JavaScript application features such as caches and undo buffers need to know the memory consumption of objects in order to function effectively. There are a total of 3 memory objects namely:

  • jsHeapSizeLimit
  • totalJsHeapSize
  • usedJsHeapSize.

2. What is a heap in JavaScript?
a) Collection of Java objects
b) Collection of JavaScript objects
c) Collection of memory usage values
d) Collection of data stored in memory
View Answer

Answer: b
Explanation: A heap is a tree-like data structure where each node must be ordered with respect to the value of its children. The heap is the collection of JavaScript objects that the interpreter keeps in resident memory.

3. What is the function of the memory object?
a) Gets unused memory details
b) Shows optimization
c) Gets memory usage
d) Memory optimization
View Answer

Answer: c
Explanation: The JavaScript Memory column represents the JS heap. This column contains two values. The value you’re interested in is the live number (the number in parentheses). The memory object is a feature of Chrome that allows us to see the memory usage that Chrome is taking up while running our page.
advertisement
advertisement

4. What is the command to access the Heap size limit?
a) performance.memory. SizeLimit
b) performance.memory. jsHeapSizeLimit
c) jsHeapSizeLimit
d) performance.jsHeapSizeLimit
View Answer

Answer: b
Explanation: Memory contains an object created with MemoryInfo constructor, containing jsHeapSizeLimit, totalJSHeapSize and usedJSHeapSize properties with numerical values. The command performance.memory. jsHeapSizeLimit is used to access the Heap size limit.

5. What is the purpose of garbage collection?
a) Removes object with many reference
b) Removes object with reference
c) Removes object with invalid reference
d) Removes object with no reference
View Answer

Answer: d
Explanation: When the interpreter sees an object in the heap with no object references, it removes that object from the heap. This is called garbage collection. An object is considered garbage collectible if there are zero references pointing at this object.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. What does the usedJsHeapSize property indicate?
a) Amount of memory used
b) Amount of memory unused
c) Amount of memory used & unused
d) Amount of memory required
View Answer

Answer: a
Explanation: usedJsHeapSize returns an object of type ObjectObject. An object created with MemoryInfo constructor, containing jsHeapSizeLimit, totalJSHeapSize and usedJSHeapSize properties with numerical values. The usedJsHeapSize property is the amount of memory that all of the current objects in the heap are using.

7. Which of the following property indicate the total size of the heap?
a) heapSize
b) totalHeapSize
c) totalJsHeapSize
d) totalHeap
View Answer

Answer: c
Explanation: usedJsHeapSize stores an object created with MemoryInfo constructor, containing jsHeapSizeLimit, totalJSHeapSize and usedJSHeapSize properties with numerical values.
advertisement

8. What can be done to monitor the memory usage?
a) Profiling
b) Sequencing
c) Serializing
d) Serializing & Sequencing
View Answer

Answer: a
Explanation: Garbage collected languages help developers manage memory by periodically checking which previously allocated pieces of memory can still be “reached” from other parts of the application. Profiling allows us to monitor our memory usage.

9. Which of the following gives the high level breakdown of memory usage?
a) about:memory
b) memory
c) about-memory
d) about::memory
View Answer

Answer: a
Explanation: The Memory column represents native memory. DOM nodes are stored in native memory. If this value is increasing, DOM nodes are getting created. Typing about:memory into the location bar brings up a page that gives a high-level breakdown of memory usage.
advertisement

10. Which keyword must be used to get a more granular insight into the memory usage?
a) verb
b) verbose
c) granule
d) gran
View Answer

Answer: b
Explanation: Memory column represents native memory. To get a more granular insight into the memory usage, we must type about:memory?verbose.

Sanfoundry Global Education & Learning Series – Javascript Programming.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.