This paper is concerned with a nonlinear optimization problem that naturally arises in population biology. We consider the population of a single species with logistic growth residing in a patchy environment and study the effects of dispersal and spatial heterogeneity of patches on the total population at equilibrium. Our objective is to maximize the total population by redistributing the resources among the patches under the constraint that the total amount of resources is limited. It is shown that the global maximizer can be characterized for any number of patches when the diffusion rate is either sufficiently small or large. To show this, we compute the first variation of the total population with respect to resources in the two patches case. In the case of three or more patches, we compute the asymptotic expansion of all patches by using the Taylor expansion with respect to the diffusion rate. To characterize the shape of the global maximizer, we use a recurrence relation to determine all coefficients of all patches.