<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def arrayCast(source, dtype):
 	""" 	Casts a NumPy array to the specified datatype, storing the copy 	in memory if there is sufficient available space or else using a 	memory-mapped temporary file to provide the underlying buffer. 	"""

	
	# Determine the number of bytes required to store the array
	requiredBytes = _requiredSize(source.shape, dtype)
	
	# Determine if there is sufficient available memory
	vmem = psutil.virtual_memory()
	if vmem.available > requiredBytes:
		return source.astype(dtype, subok=False)
	else:
		dest = arrayFactory(source.shape, dtype)
		np.copyto(dest, source, casting='unsafe')
		return dest