Entropy generation and the survival of protogalaxies in an expanding universe