Stimulated by recent experimental results, we simulate "temperature"-cycling experiments in a model for the compaction of granular media. We report on the existence of two types of memory effects: short-term dependence on the history of the sample, and longterm memory for highly compact (aged) systems. A natural interpretation of these results is provided by the analysis of the density heterogeneities.