We study the asymptotic behavior of the solutions to a family of discounted Hamilton-Jacobi equations, posed in R N , when the discount factor goes to zero. The ambient space being noncompact, we introduce an assumption implying that the Aubry set is compact and there is no degeneracy at infinity. Our approach is to deal not with a single Hamiltonian and Lagrangian but with the whole space of generalized Lagrangians, and then to define via duality minimizing measures associated to both the corresponding ergodic and discounted equations. The asymptotic result follows from convergence properties of these measures with respect to the narrow topology. We use as duality tool a separation theorem in locally convex Hausdorff spaces, we use the strict topology in the space of the bounded generalized Lagrangians as well.