Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[HACK] Fixing "java.lang.OutOfMemoryError" when using ant
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
jannis
Guru
Guru


Joined: 05 Dec 2004
Posts: 335
Location: Germany / Bavaria / Aschaffenburg

PostPosted: Mon Oct 03, 2005 6:36 pm    Post subject: [HACK] Fixing "java.lang.OutOfMemoryError" when us Reply with quote

Ok, just some words before you come to me screaming afterwards:
I'm using ~x86. What I explain here is a very dirty hack to get things work because I don't know a better way yet. You do this at your own risk!

When I tried to emerge "net-p2p/azureus-2.3.0.4" it stopped with this error:
Quote:
"java.lang.OutOfMemoryError: Java heap space"


After searching a while I found out that the memory "java" uses is limited to 64MB by default. This is what causes the error because ant needs more to compile azureus. Changing the ebuild (using a portage overlay directory) didn't help bcause the param "-Xmx512M" needs to be passed to java before the jar-file is specified. This is not possible in the ebuild so I added the param to "/usr/bin/ant". Open "/usr/bin/ant" with your favorite editor (this is not an ELF or any other binary-file, it is a shell-script), go to the very end of the file (it's line 164/170 with dev-java/ant-1.6.5) and you will see the line:
Quote:
ant_exec_command="exec \"$JAVACMD\" $ANT_OPTS -classpath [...]

change it so it reads:
Quote:
ant_exec_command="exec \"$JAVACMD\" -Xmx512M $ANT_OPTS -classpath [...]


This will allow ant to allocate 512MB of RAM. This is ok for my PC, if you have less RAM you should try 256MB or so.


Forum Mods: If this is too dirty, please move to "Unsupported Software", I wasn't quite sure where to place this. Thanks.
Back to top
View user's profile Send private message
incabolocabus
Apprentice
Apprentice


Joined: 24 Nov 2003
Posts: 232
Location: Fort Collins, CO

PostPosted: Mon Oct 03, 2005 7:01 pm    Post subject: Reply with quote

Instead, just use
Code:
ANTOPTS="-Xmx256M" ant/emerge


a bug should be filed for the ebuild to do this itself...
_________________
1970s Sears Hawthorne, green, 3 gears, front and rear fenders, rear dual basket rack, overclocked to 1.3 hz.
Back to top
View user's profile Send private message
incabolocabus
Apprentice
Apprentice


Joined: 24 Nov 2003
Posts: 232
Location: Fort Collins, CO

PostPosted: Mon Oct 03, 2005 7:02 pm    Post subject: Reply with quote

ant/emerge = you are either using ant alone (like for your own projects) or with emerge
_________________
1970s Sears Hawthorne, green, 3 gears, front and rear fenders, rear dual basket rack, overclocked to 1.3 hz.
Back to top
View user's profile Send private message
jannis
Guru
Guru


Joined: 05 Dec 2004
Posts: 335
Location: Germany / Bavaria / Aschaffenburg

PostPosted: Tue Oct 04, 2005 5:01 am    Post subject: Reply with quote

Ok, I didn't know that using ANTOPTS="-Xmx256M" was possible, thanks for the hint.
Back to top
View user's profile Send private message
bushwakko
Guru
Guru


Joined: 25 Mar 2003
Posts: 495

PostPosted: Fri Oct 07, 2005 3:22 pm    Post subject: Reply with quote

lapwakko ~ # ANTOPTS="-Xmx512M" emerge azureus

I get the same error:

SCII
[javac] * Created : 7 d???c. 2003}
[javac] ^
[javac] /var/tmp/portage/azureus-2.3.0.4/work/azureus/org/gudy/azureus2/ui/swt/views/utils/ManagerUtils.java:3: warning: unmappable character for encoding ASCII
[javac] * Created : 7 d???c. 2003}
[javac] ^
[javac] /var/tmp/portage/azureus-2.3.0.4/work/azureus/org/gudy/azureus2/ui/swt/views/utils/ManagerUtils.java:3: warning: unmappable character for encoding ASCII
[javac] * Created : 7 d???c. 2003}
[javac] ^


[javac] The system is out of resources.
[javac] Consult the following stack trace for details.
[javac] java.lang.OutOfMemoryError: Java heap space
_________________
Macbook Pro 15"
Core 2 Duo 2,33ghz
2gb Ram
ATI Mobility x1600 256mb
Back to top
View user's profile Send private message
magowiz
Veteran
Veteran


Joined: 17 Feb 2005
Posts: 1029
Location: Italy/Milan/Bresso

PostPosted: Tue Nov 01, 2005 2:01 pm    Post subject: Reply with quote

I also tried to invoke emerge azureus with ANTOPTS="-Xmx512M" or ANTOPTS="-Xmx256M" but it gives me always the same error :
Code:


[javac] The system is out of resources.
    [javac] Consult the following stack trace for details.
    [javac] java.lang.OutOfMemoryError: Java heap space
ANTOPTS="-Xmx256M" emerge azureus
Calculating dependencies ...done!
>>> emerge (1 of 1) net-p2p/azureus-2.3.0.4 to /
>>> md5 files   ;-) azureus-2.3.0.4.ebuild
>>> md5 files   ;-) azureus-2.2.0.0-r1.ebuild
>>> md5 files   ;-) files/digest-azureus-2.2.0.0-r1
>>> md5 files   ;-) files/UpdaterPatcher.java
>>> md5 files   ;-) files/azureus-gentoo.sh
>>> md5 files   ;-) files/digest-azureus-2.3.0.4
>>> md5 files   ;-) files/azureus.desktop
>>> md5 files   ;-) files/build.xml
>>> md5 files   ;-) files/azureus-gentoo-2.3.0.4.sh
>>> md5 files   ;-) files/SWTThread.java
>>> md5 files   ;-) files/azureus.png
>>> md5 src_uri ;-) Azureus_2.3.0.4_source.zip
>>> md5 src_uri ;-) seda-20040224.zip
>>> Unpacking source...
>>> Unpacking Azureus_2.3.0.4_source.zip to /var/tmp/portage/azureus-2.3.0.4/work/azureus
>>> Unpacking seda-20040224.zip to /var/tmp/portage/azureus-2.3.0.4/work/azureus>>> Source unpacked.


    [javac] The system is out of resources.
    [javac] Consult the following stack trace for details.
    [javac] java.lang.OutOfMemoryError: Java heap space

BUILD FAILED
/var/tmp/portage/azureus-2.3.0.4/work/azureus/build.xml:4: Compile failed; see the compiler error output for details.

Total time: 17 seconds

!!! ERROR: net-p2p/azureus-2.3.0.4 failed.
!!! Function src_compile, Line 61, Exitcode 1
!!! ant build failed
!!! If you need support, post the topmost build error, NOT this status message.


I've got ~1GB of RAM + ~1GB of swap, sun jdk 1.5 as default jdk.
Back to top
View user's profile Send private message
magowiz
Veteran
Veteran


Joined: 17 Feb 2005
Posts: 1029
Location: Italy/Milan/Bresso

PostPosted: Tue Nov 01, 2005 2:19 pm    Post subject: Reply with quote

I solved : the correct variabile is not ANTOPTS but ANT_OPTS, as described in this bugreport :
https://bugs.gentoo.org/show_bug.cgi?id=81924
Back to top
View user's profile Send private message
jannis
Guru
Guru


Joined: 05 Dec 2004
Posts: 335
Location: Germany / Bavaria / Aschaffenburg

PostPosted: Tue Nov 01, 2005 2:27 pm    Post subject: Reply with quote

Thanks for this nice hint magowiz
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum