   cudaFree(d_grid_dims);
   cudaFree(d_u_vals);
   cudaFree(d_v_vals);
+  cudaFree(d_valids);// was missing
 
 }
 

 */
void ElasGPU::computeDisparity(std::vector<support_pt> p_support, std::vector<triangle> tri, int32_t* disparity_grid, int32_t *grid_dims,
                                uint8_t* I1_desc, uint8_t* I2_desc, bool right_image, float* D) {

  // number of disparities
  const int32_t disp_num  = grid_dims[0]-1;
  

  delete valids;

  // Free big memory

  cudaFree(d_planes_a);
  cudaFree(d_planes_b);
  cudaFree(d_planes_c);
