In this paper, we consider finite- and infinite-dimensional optimization problems with constraints of general type. We obtain sufficient conditions for stability of a strict solution and conditions for stability of a set of solutions with more than one point in it according to small perturbations of the problem parameters. For finite-dimensional extremal problems with equality-type constraints, we obtain stability conditions based on the construction of λ-truncations of mappings.