Process of heating of thin layer located between two vibrating surfaces is studied. Energy loss goes on due to viscous or dry friction. Optimal quantities of shear viscosity and friction corresponding to maximum energy loss are determined. Resonant behavior of loss must be taken into account in the description of "slow dynamics" of rocks and materials exposed to high-intensity seismic or acoustic irradiation as well as in various technologies. Bonding of materials by linear friction welding, widely used in propulsion engineering, can exemplify such a technology.