buffer is allocated 1024 bytes