Github Copilot · Free Practice Question Medium
Question 21
You are debugging a memory leak in a Node.js web application that gradually consumes more memory, causing performance issues. You've identified the leak but not its source. How can GitHub Copilot best assist in debugging and tracking down the leak?
-
A
Use GitHub Copilot to generate functions that track memory usage at specific intervals, helping you monitor which parts of the code are leaking memory.
-
B
Use GitHub Copilot to replace manual debugging steps entirely, trusting its suggestions without monitoring the impact on the system’s performance.
-
C
Use GitHub Copilot to automatically rewrite the memory management parts of the code, assuming it will fix the issue.
-
D
Use GitHub Copilot to suggest random optimizations throughout the codebase, assuming they will reduce memory consumption.
Reveal correct answer
Correct answer: A
A.
This is the best approach. GitHub Copilot can assist by suggesting code snippets that monitor memory usage at regular intervals. By tracking memory usage in real-time, you can identify which parts of the code are responsible for the leak, making it easier to debug. This approach allows for data-driven debugging and quicker problem identification.
B.
Relying entirely on Copilot to debug without manual intervention and system monitoring is a flawed approach. Copilot is a tool that aids developers, but debugging often requires careful observation of performance metrics and understanding of the system behavior, which Copilot cannot replace entirely.
C.
Automatically rewriting memory management code is not a reliable approach. Memory leaks often result from subtle issues such as improper object references or event listeners, which Copilot may not accurately fix by just rewriting sections of the code without deeper analysis.
D.
Randomly optimizing code without understanding the root cause of the memory leak is inefficient. Not all optimizations will address memory management issues, and introducing random changes can create additional complexity or bugs.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
