Overview:
I have a NodeJS server with a few C++ modules in it, executing one overall "job". Some objects (C++ objects, let's say "singletons") in these modules are common and their states after initialization should be shared between each module. The initialization of those objects has to be done once during server startup.
Example:
A, B - separate C++ modules which should be executed as one job
x, y, z - shared C++ objects (possibly a lot of them)
Questions:
Can you tell me if there is some known best practice of initialization and sharing of these objects between all C++ modules?
What is the lifecycle of a particular C++ module in NodeJS? When are they removed from the memory?