If running Tomcat as a Linux daemon, open the /etc/init.d/Tomcat.sh script and append the parameters to the CATALINA_OPTS variable: i.e.
If CATALINA_OPTS is already set to this: CATALINA_OPTS="-Djava.library.path=/opt/tomcat/lib/.libs"
then change it to this: CATALINA_OPTS="-Djava.library.path=/opt/tomcat/lib/.libs -Xmx512m -Xms512m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:NewSize=128m"
For Ubuntu, see Jonah Mwogi's directions in the comments below .
Solution for Tomcat memory leak:
YourKit is kindly supporting OpenMRS with its full-featured Java Profiler. YourKit, LLC is creator of innovative and intelligent tools for profiling Java and .NET applications. Take a look at YourKit's leading software products: YourKit Java Profiler and YourKit .NET Profiler.