The total energy of an array of dislocations in a strained epitaxial layer is composed of the self energy of the dislocations, the strain energy which arises from the lattice mismatch between the layer and its substrate and the interaction energy between the dislocations and the mismatch strains. The sum of the self energy and the interaction energy represents the formation energy of the dislocations. In this study, the self energy is formulated using complex potentials. Two limiting conditions are used to check the solution. The first is that the self energy of the array reduces to that for an isolated single dislocation as the dislocation spacing in the array approaches infinity. Secondly, as the layer thickness approaches infinity, the self energy reduces to that for a dislocation wall. A negative formation energy promotes dislocation generation while a positive formation energy implies a suppression of dislocation generation. A critical thickness required for the generation of an isolated dislocation is found by locating the layer thickness which corresponds to a zero value of the formation energy. The critical dislocation density at a given thickness is also determined.