Unexpectedly, our home PC has been coming to a sudden halt multiple times over the past few days. It takes nearly half an hour for the UI to recover, sometimes requiring a hard reboot. Upon checking Task Manager, I discovered that one specific PID is consuming approximately 96% of the PC's RAM. Through Chrome Task Manager, I identified it as a webpage created by me.
While I have only some knowledge about memory leaks from hearing about them in passing, I strongly believe that my Javascript code may be causing a memory leak. Is there a recommended practice to modify the code and prevent memory leaks? The suspicion lies on my response()
function.
Prior to dismissing this inquiry due to duplication or lack of investigation, I refer to another Stack Overflow post which suggests that case "12124561414":
could be the root cause; however, verification was inconclusive. Additionally, the loop within this function does not execute, making it uncertain if that's truly responsible, as I am unaware of any built-in JS tools to identify memory leaks.
Is there a way to run continuous loops without triggering memory leaks (if indeed that’s causing the issue)? Or how can resources seemingly unused be freed up? My intention is to have the busy tone play indefinitely until the page refreshes, but crashing the computer seems unjustified.
The complete JS code for the webpage is provided below:
[JS code here]
This alternative approach appears promising, albeit untested due to concerns about further PC crashes:
[Modified JS code here]