Allocate and free memory VS. allocate first, process only for each time

Once upon a time, I was trying to write some code for some robot hardware's serial communication part. I had a desktop pc, no memory restrictions (8GB RAM, i3 CPU etc.) and that particular program communicated with microcontroller via USB(Fullspeed) or Serial with 115200 baudrate. I had around 20 to 30 methods which used this communication function and because of that I was really curious how its processing time affected my work.. Only one instance of this function is running at the same time. The question is... Which one is more effective to process data faster? 1. Define first, use every time; ... private : struct timespec ctv1 , ctv2 ; double time_diff ; int serial_write_ret ; int ret_val ; ... int MSerial :: genAndSend_setInt32Command () { genSum ( stm_buf_t ); sem_wait ( & serial_mutex ); // someFunctions(); sem_post ( & serial_mutex ); return ret_val ; } 2. Or allocate and deallocate every t...