you can read this article. url is below. explain how to manage memory. But In my opinion. this is a design problem, not a memory problem.
help! could anybody know how to increase heap size when you start Java applicaton? (like java -Xmx<size>)