I have what seems to be a huge memory leak in my node.js app, but when I use node-webkit-agent to examine the heap, it seems quite small. I suspect that there may be a whole ton of async operations queued up on the node.js event queue, but I'm not sure how to examine that. Is there any way to do so?
By putting it in the queue (as opposed to just running it directly) we allow the event loop to continue looping and thus prevent the main thread from blocking. As a result, the console. log is called exactly once per event loop iteration (within each timer phase to be exact).
Using the Node. To connect to it, open up Google Chrome and enter about:inspect into the URL bar and press Enter. Afterward, you will be redirected to chrome://inspect/ and be presented with a list of available devices to debug. If successful, your screen should show something similar to the image below.
The event queue is built in. It pushes events onto the call stack, also built in, as they occur. Calls on the call stack do not get called until current call has been completed. – Blindman67.
Since Node. js applications are event-driven, the events are triggered on its associated event handler. An event handler is nothing but a callback function called when an event is triggered. The main loop listens to the event triggers and then calls the corresponding event handler.
You can check open handles and requests by inspecting the return values of the undocumented functions process._getActiveHandles()
and process._getActiveRequests()
respectively. That won't get you everything that may be waiting in the event loop, but it should help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With