Added getFreeMem function to helper Functions