mem checks for failed allocation of memory for strings