Tom Maxwell
Tom Maxwell

Reputation: 9573

Java: Finding the cause of OutOfMemoryError

I'm trying to build a Java app in my Terminal (I'm using Eclipse, but Terminal just to see if it works), and I keep getting stuck at this message:

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread     "main"

It was recommended that I add this line of code to my .profile (I have a .bash_profile, but not a .profile), so I did:

MAVEN_OPTS="-XX:MaxPermSize=512m"

But I'm still getting the error. Here's what my .bash_profile file looks like:

if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi

MAVEN_OPTS="-XX:MaxPermSize=512m"

export JAVA_HOME=/usr/lib/jvm/java-7-oracle

export PATH=$PATH:/usr/local/mysql/bin

##
# Your previous /Users/tom.maxwell/.bash_profile file was backed up as   /Users/tom.maxwell/.bash_profile.macports-saved_2013-03-04_at_15:51:37
##

# MacPorts Installer addition on 2013-03-04_at_15:51:37: adding an appropriate PATH        variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.


##
@                                                                               
".bash_profile" 46L, 1730C

What should I do? The app I'm trying to run is quite large, and I'm not familiar with Java (I'm mostly a JS/CSS person).

Upvotes: 3

Views: 4040

Answers (3)

Neelam
Neelam

Reputation: 370

I am using Ubuntu 14.04 and I was facing the similar issue. The thing that worked for me is adding this line to .bashrc

export MAVEN_OPTS="-Xmx756m -XX:MaxPermSize=2048m"

After that just restart your system.

Upvotes: 1

Borja
Borja

Reputation: 3610

Add this parameter as argument in your server params

-Xmx1024m -XX:MaxPermSize=512m -Xms512m

enter image description here

Upvotes: 0

kritzikratzi
kritzikratzi

Reputation: 20221

you're changing the permgen size which holds classes and stuff.

instead you want to change maximum memory, adding MAVEN_OPTS="-Xms512M -Xmx2048M"

should fix your problem.

Upvotes: 2

Related Questions