[DF-2992] fixes on memory management for NMaterial