memory optimization for klvd method.