Process object memoryUsage()

Hi there,

I'd like to access the process object inside the function code, such as to know the memory usage of the runtime:

msg.payload = process.memoryUsage()

Is there a way to do this?

Thanks

Hi @namgk,

If you are running Node red 1.3 or greater you can enable in your settings.js file the option to load additional modules (as is the node.js process module).

More info on this new functionExternalModules Node-red feature here

Once you have that setup .. all you have to do is require the module and use it in the function with the command you have in your post.

image

image

Test Flow

[{"id":"8045d8233a0fa439","type":"function","z":"4895ea10b4ee9ead","name":"","func":"msg.payload = process.memoryUsage()\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[{"var":"process","module":"process"}],"x":620,"y":620,"wires":[["43219ebdd7140cf2"]]},{"id":"5e2779f67bfafe2b","type":"inject","z":"4895ea10b4ee9ead","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":470,"y":620,"wires":[["8045d8233a0fa439"]]},{"id":"43219ebdd7140cf2","type":"debug","z":"4895ea10b4ee9ead","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":780,"y":620,"wires":[]}]
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.