One of Key challenges i faced on my last project is to get rid of Out of memory problem. Here are the few things one can do to avoid the problem :
1. Increase the Heap size on Application server. ( This solution is not permanent one and for a large application this will not result any significance improvement )
2. On your code make sure that all the Object destroyed after use. Please read the detail article from How to Handle Java Finalization's Memory-Retention Issues.
Wish this article helped you to get rid of memory Problem ,