use mapped buffer instead of reallocation