I've experienced this before, and all you can do is cry.
This is why agile is so important. Instead of one person making all of the decisions, you have a team that makes the decisions. The "manager" tends to fall into just a product owner role, which is a good thing. In a team situation, the intern would have had a chance to put out his ideas as to a solution.
In agile, they would have been in two to four week intervals, so rather than a 5 month development period, the stakeholders (i.e. the boss) would have seen partial results in a month or less and would have been able to decide if the cost of what was happening was worth it. Probably the team would have concluded that other than a little optimization, the adding of more memory was the best solution.
Go Agile, it's worth it.