added alMalloc, found segFault problem inside gradMag