The diets of dogwhelks, Nucella lapillus, feeding naturally on the shore, were monitored continually. The sizes of prey eaten were compared with those available and foraging behaviour was related to prevailing weather conditions. Foraging behaviour varied widely among individuals, even within localized areas. Growth was correlated with cumulative energy intake and individuals that rarely fed lost weight. Foraging behaviour was constrained by weather conditions associated with heavy wave action in exposed places and desiccation in shelter. Under favourable circumstances, dogwhelks avoided smaller prey, so behaving as energy maximizers. Unfavourable weather confined the dogwhelks to the vicinity of refuges, restricting the choice of prey or preventing foraging altogether. Dogwhelks, therefore, provide a natural example of constrained optimization in foraging behaviour.