For 29 generations, populations of Drosophila melanogaster were offered one favourable (standard) and one suboptimal (salt-supplemented) medium, either singly or simultaneously. Egg-to-adult viability, fecundity and choice of oviposition medium were measured at regular intervals on both resources up to 17 generations after initiation of the salt treatment. Except for a decrease in viability on salt medium in the single-resource populations (SRPs) maintained on the optimal medium, these fitness components remained unchanged. Estimation of a more inclusive measure of fitness, productivity, obtained at generations 27–29, revealed that: (1) the SRPs maintained on salt medium were more adapted to salt medium; (2) the mixed-resource populations (MRPs) were intermediate in their adaptation to salt medium between either type of single-resource population. These results support Levins' model of optimal strategy for populations living in a coarse-grained environment when the fitness set is convex. Family selection for increased and decreased resistance to salt in the medium, carried out for the viability component at generations nine and 19, showed that: (1) genetic variation with respect to this component was present in all populations; (2) the SRPs maintained on salt medium had responded to the salt treatment by eliminating sensitive genotypes; (3) in the first selection experiment, the MRPs had a greater amount of additive genetic variance with respect to viability than either type of SRP; in the second experiment, this difference was not significant, but it was in the predicted direction. The latter finding provides some evidence in favour of the hypothesis repeatedly presented in the literature that environmental heterogeneity could promote the maintenance of genetic variability in populations.