Profiling nsock and studying the I/O patterns of nmap would help us optimize the way we perform I/O and use memory in nsock.
using i/o vectors (see readv/writev) could improve efficiency and memory footprint (or not) depending on what the profiling reveals.