In the case of NodeJS, which use the V8 Engine [0], you have access to the diagonistics API [1] that allows you profile your cpu or memory consumption.
There are some tools that make that easier (see [2] or [3]) but you often left to interpret the result yourself