Spin inertia measurements are a novel experimental tool to study long-time spin relaxation processes in semiconductor nanostructures. We develop a theory of the spin inertia effect for resident electrons and holes localized in quantum dots. We consider the spin orientation by short optical pulses with arbitrary pulse area and detuning from the trion resonance. The interaction with an external longitudinal magnetic field and the hyperfine interaction with the nuclear spin bath is considered both in the ground and excited (trion) states of the quantum dots. We analyze how the spin inertia signal depends on the magnetic field (polarization recovery), on the modulation frequency of the helicity of the pump pulses as well as on their power and detuning. In particular, we elaborate how approaching the saturation limit of the spin polarization influences the measurements. The quantitative description of spin inertia measurements will enable the determination of the parameters of spin dynamics such as the spin relaxation times in the ground and excited states and the parameters of the hyperfine interaction. Finally, we predict a novel longitudinal spin mode locking effect, which manifests itself as oscillations of the spin polarization as function of the longitudinal magnetic field.