Which is the larger amount of memory required - cvCreateMat or the PCA analysis? Allocate it once and use it for both? Why deallocate when your going to need it again shortly anyway? Even if it is for another task.