Profile-guided memory layout: theory and practice