There you have the conservation of the sum of potential energy and kinetic energy, and now, of course, you cannot afford to lose kinetic energy through heat, because then the conservation of mechanical energy would not hold, and so that can only be used exclusively in the case of conservative forces. 