in reply to Re^3: Handling multiple clients
in thread Handling multiple clients
Fork will share the memory. If One process modifieds a place in memory, it's whole 4K block will get copied and made exclusive to that process.
This means that although top will show all your processes using 2Gb Virtual Mem, they in fact share the 2Gb Physical Mem which you are using, provided none of them modifies any of the data.
For futher optimisation, you should open+mmap+close the data files instead of doing open+read+close, so that you really use the data files as the backing store for your queries.
The OS will then optimize the memory as best as it can.