The desorption of bubbles during solidification of a melt occurs in processes as diverse as the making of ice cubes, the formation of igneous rocks and the casting of metals. In both the metal casting and rock formation processes, careful observation of the final solid suggests that the desorbed bubbles often form regular spatial patterns. Understanding and quantifying the mechanisms by which such patterns arise is important. In the geological context, comparison between field measurements and the predictions of a model will allow geologists to estimate in-situ magma properties. In the metal casting context, engineers would like to be able to specify mould geometries and cooling conditions to ensure that the distribution of bubbles will not compromise the strength of critical sections of the casting.In the present study, we develop a detailed mathematical model to predict the distribution of desorbed bubbles in a solidified melt. Our new model builds upon previous knowledge on this phenomenon in the geological context (Toramaru et al. 1996, 1997). We describe desorption of a dissolved gas in a semi-infinite melt, solidified by a one-dimensional heat flux. In the absence of convection, the transfer of heat and solute occurs mainly by a diffusive mechanism and the crystallization proceeds most rapidly near the cooled boundary. The crystals formed contain almost no dissolved gas and hence the concentration of gas dissolved in the melt increases progressively towards the cooled boundary. Diffusion of dissolved gas from the crystallizing zone is slow and, as a result, the local melt becomes supersaturated and gas bubbles desorb. The full equations for this coupled solidification and desorption processes are solved numerically.We find that bubbles desorb forming a sequence of layers parallel to the cooled boundary. The spacing between these bubble layers increases geometrically from the cooled boundary. We give a physical interpretation for this geometric pattern and analyse the effect of physical parameters on the layer spacing. We show that our theoretical model captures the important physical mechanisms involved in the solidification and desorption processes by comparing its predictions with available measurements from a geological formation.