Just keep futzing around with it for another six months or so, until your employer's client realizes that someone who doesn't know what he's doing is not cheaper than someone who does. No one can look at a single statement in a program and somehow divine why it's using a lot of memory. Nor is anyone going to be willing to take the entire program (should you respond to this comment, as so many do, by dumping it all into a reply and saying "fix it for me") and fix it for you.