Both hydrogen (as H2) and helium are dissolved endothermically in crystalline silicon. Once implanted into silicon, they have therefore a tendency to segregate in the vacancy clusters produced by the implantation itself, possibly transforming them in more or less stable cavities. Since the amount of vacancies generated in silicon by the implantation of hydrogen or helium at low energy, and surviving the spontaneous recovery of the radiation damage, may be lower than the amount of the implanted species, the atomic density attained after the cluster-to-cavity transformation may exceed the silicon one, with the formation of ultradense gas bubbles. The major difference between hydrogen and helium is that the pristine state of hydrogen in as-implanted silicon is not the molecular one, so that the formation of cavities requires preliminarily the transformation of hydrogen-involving species in H2. This paper highlights the mechanisms of cavity formation by helium or hydrogen implantation and sketches analogies and differences between these processes; coimplantation is discussed too.