Perturbative expansions of physical quantities such as free energies can give us some insight into the weakly coupled regime of the theory we started from. But such expansions are often divergent and defined only as asymptotic series. In fact, this divergence is connected to the existence of nonperturbative contributions, i.e. instanton effects that cannot be captured by a perturbative analysis. The theory of resurgence is a mathematical tool which allows us to effectively study this connection and its consequences. This will be the main subject of this talk, specifically how one can construct a full nonperturbative solution from pertubative data, and how this relates to the existence of background independence in matrix models.