Solar System formation, considering its and the universe's age It is known that the Sun is 4.6 billion years old, and the complete Solar System is of a similar age. The class of stars to which the Sun belongs seems to be quite common. Stars of its class can live for 8 or 9 billion years before moving to the red giant stage. Also, the whole universe is less than 14 billion years old.

Thus, not many generations of Sun-like stars could have existed before the first stages of our Solar System. And heavy elements are created when stars collapse. While there could be a lot of star classes with much shorter lifespans, I'm wondering: where do the heavier elements came from? Not only for our Solar System, but many others. I think it is very likely that our Solar System is of average age; do the numbers match between dead stars and remote stellar systems? Are there studies about this?
Early in the life of the universe it is thought that star formation in "metal-free" gas probably favoured larger stars. These Population III stars had short lives and very quickly enriched the interstellar and intergalactic medium with nucleosynthesis products.

In fact the main enrichment of the interstellar medium (ISM) in our own Galaxy is thought to have taken place some billions of years before the Sun was born. Stars that are being formed now have basically the same composition as the Sun. The plot below shows the iron abundance (on a logarithmic scale) as a function of deduced age for stars in the Gaia-ESO spectroscopic survey (from Bergemann et al. 2014). As you can see, there has not been too much change in iron abundance over the last 10 billion years.


I think the key to this is that most of the heavy elements in the gas in our Galaxy come from stars more massive than the Sun, and which have much shorter lifetimes as a result. [Stellar lifetime is roughly proportional to $M^{-2.5}$]. So several "generations" of these have lived and died (and must have done so).

To add some more detail. Almost all the elements heavier than Helium (known as "metals") are produced inside stars. To get back into the ISM you have to get the "processed" material out of the centres of the stars. This occurs in basically three ways. (i) Supernovae - the explosions associated with the final collapse of very massive stars ($&gt;10 M_{\odot}$). The supernova progenitors have short lives $&lt;50$ million years, so many generations of such stars can have lived and died before the Sun was formed, and probably of order a few hundred million to a billion had done so. (ii) Giant star winds. These occur towards the ends of the lives of stars with mass of $&lt;10M_{\odot}$. Some fraction of processed material gets dredged out of the centre and expelled into the ISM. The lifetimes of these stars is 50 million to $&gt;10$ billion years. Most of the enrichment is caused by stars about in the middle of this range. These stars go on to fade as white dwarfs. (iii) Type Ia supernovae. Explosions triggered by mass transfer on to a white dwarf (probably in binary systems) causing a detonation and the scattering of metals into the ISM. Progenitors have lifetimes similar to the giant stars in (ii).

If you look carefully at the colour scheme of the plot above, you will notice that ancient stars have a higher ratio of magnesium to iron. This supports the ideas in the paragraph above. Magnesium is an alpha-capture element, produced mainly in short-lived massive stars and gets into the interstellar medium through type II supernovae. Conversely, although iron is also produced in massive stars, it is primarily produced and dispersed in type Ia supernovae that have much longer lived progenitors. Thus Mg enrichment occurs more rapidly than Fe enrichment in the early Milky Way. 

The numbers of white dwarfs we see in the Galaxy and the deduced rate of supernova explosions that are occurring (e.g. from counting the number of neutron star remnants) also matches up with what is required to produce the metallicity of the ISM and the Sun. But there are plenty of variables and unknowns and not everything is solved. For instance it looks quite likely that star formation needed to be higher in the past; and some parts of the Galaxy (e.g. the bulge) have a higher metallicity, thought to be due to a period of very vigorous high mass star formation 10 billion years ago.