Shared memory with node.js
This is more like a tutorial on writing a simple node.js add-on to share memory among node.js processes.
One of the limitations of node.js/io.js is that they are single threaded. Only way to use multiple cores in the processor is to run multiple processes . But then you are working on different memory spaces. So it doesn’t help if you want multiple processes working on the same memory block. This is required in memory intensive tasks that cannot be efficiently sharded.
All the source code is available in Github.
node-gyp installed to build the node module.
npm install node-gyp -g
I think the node.js version matters as the addon api has changed. I was working on node 0.12.2, when I tested this out.
binding.gyp is required by node-gyp to build the addon.
shm_addon.cpp. This is a very basic addon that has one export
createSHM, which creates a...
Continue reading →