Determining the cause of RSS memory leak in NodeJS

I recently stumbled upon a memory leak in my Node.js application after migrating from MongoDB to Postgresql. The code runs on Node.js v 0.10.x. The code and its dependencies are 100% written in JS. I'm using the pg.js module to access to the database.

The problem is that I see the RSS of Node growing (until the process crashes) but not the heap and not the V8 external memory (logged via the --trace_external_memory flag). That's why none of any tools to find leaks in the V8 heap are helping me.

What could be the cause of this memory leak? For example, is it possible to have a leak related to Buffer instances which wouldn't appear in the external memory logs?

What version of Postgres are you running? There is a memory leak in pre 9.3.3 versions relative to JSON functions. From the 9.3.3 release notes:

"Fix memory leakage in JSON functions"

If possible, try upgrading to 9.3.3 or higher (9.3.5 is the most recent stable release as of this writing).