Sorry for the confusion. I'm having troubles with your udf with only 512MB. It just errors out saying "Unexpected Command".