In order to understand the evolution of the interstellar medium (ISM) of a galaxy, we have analysed the gas and dust budget of the Small Magellanic Cloud (SMC). Using the Spitzer Space Telescope, we measured the integrated gas mass-loss rate across asymptotic giant branch (AGB) stars and red supergiants (RSGs) in the SMC, and obtained a rate of 1.4x10^-3 Msun yr-1. This is much smaller than the estimated gas ejection rate from type II supernovae (SNe) (2-4x10^-2 Msun yr-1). The SMC underwent a an increase in starformation rate in the last 12 Myrs, and consequently the galaxy has a relatively high SN rate at present. Thus, SNe are more important gas sources than AGB stars in the SMC. The total gas input from stellar sources into the ISM is 2-4x10^-2 Msun yr-1. This is slightly smaller than the ISM gas consumed by starformation (~8x10^-2 Msun yr-1). Starformation in the SMC relies on a gas reservoir in the ISM, but eventually the starformation rate will decline in this galaxy, unless gas infalls into the ISM from an external source. The dust injection rate from AGB and RSG candidates is 1x10^-5 Msun yr-1. Dust injection from SNe is in the range of 0.2--11x10^-4 Msun yr-1, although the SN contribution is rather uncertain. Stellar sources could be important for ISM dust (3x10^5 Msun yr-1) in the SMC, if the dust lifetime is about 1.4 Gyrs. We found that the presence of poly-aromatic hydrocarbons (PAHs) in the ISM cannot be explained entirely by carbon-rich AGB stars. Carbon-rich AGB stars could inject only 7x10^-9 Msun yr-1 of PAHs at most, which could contribute up to 100 Msun of PAHs in the lifetime of a PAH. The estimated PAH mass of 1800 Msun in the SMC can not be explained. Additional PAH sources, or ISM reprocessing should be needed.