Check memory alloc success