Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 344135 - dev-java/icedtea6-bin-1.9.1 fail to run (Could not reserve enough space for object heap)
Summary: dev-java/icedtea6-bin-1.9.1 fail to run (Could not reserve enough space for o...
Status: RESOLVED DUPLICATE of bug 389751
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Java team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: icedtea-tracker
  Show dependency tree
 
Reported: 2010-11-04 15:49 UTC by Alex Efros
Modified: 2011-11-29 16:32 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Efros 2010-11-04 15:49:40 UTC
When dev-java/ant-core-1.8.1 failed to build I noticed java fail to run if not given option to limit heap size. Google suggests it happens because on system with 4GB or more RAM java try to start in -server mode. Sadly, but looks like icedtea VM doesn't support environment variable like JAVA_OPTS, so I can't work around this issue by just `export JAVA_OPTS="-client"`.

home ~ # java-config-2 -L
The following VMs are available for generation-2:
*)      IcedTea6-bin 1.9.1 [icedtea6-bin]

home ~ # java -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

home ~ # java -server -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

home ~ # java -client -version
java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.1) (Gentoo build 1.6.0_20-b20)
OpenJDK Client VM (build 19.0-b06, mixed mode)

home ~ # java -Xmx1024m -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

home ~ # java -Xmx512m -version
java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.1) (Gentoo build 1.6.0_20-b20)
OpenJDK Server VM (build 19.0-b06, mixed mode)

home ~ # free
             total       used       free     shared    buffers     cached
Mem:       4137388    3008040    1129348          0     505076    1134520
-/+ buffers/cache:    1368444    2768944
Swap:      4200956      60476    4140480

home ~ # ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 32320
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 32320
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

Also I should note SOMETIMES java success to run even in -server mode on my system:

home ~ # for i in $(seq 1 100); do java -version &>/dev/null && echo ok; done | wc -l
12
home ~ # for i in $(seq 1 100); do java -client -version &>/dev/null && echo ok; done | wc -l
100


Reproducible: Always

Steps to Reproduce:
1. java -version
2.
3.

Actual Results:  
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

Expected Results:  
java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.1) (Gentoo build 1.6.0_20-b20)
OpenJDK Server VM (build 19.0-b06, mixed mode)

Portage 2.1.8.3 (hardened/linux/x86/10.0, gcc-4.4.4, glibc-2.11.2-r3, 2.6.32-hardened-r22 i686)
=================================================================
System uname: Linux-2.6.32-hardened-r22-i686-Intel-R-_Core-TM-2_CPU_6600_@_2.40GHz-with-gentoo-1.12.13
Timestamp of tree: Tue, 02 Nov 2010 17:30:01 +0000
app-shells/bash:     4.1_p7
dev-java/java-config: 2.1.11
dev-lang/python:     2.6.5-r3, 3.1.2-r4
dev-util/cmake:      2.8.1-r2
sys-apps/baselayout: 1.12.13
sys-apps/sandbox:    2.3-r1
sys-devel/autoconf:  2.13, 2.65-r1
sys-devel/automake:  1.9.6-r3, 1.10.3, 1.11.1
sys-devel/binutils:  2.20.1-r1
sys-devel/gcc:       4.4.4-r2
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.2.10
sys-devel/make:      3.81-r2
virtual/os-headers:  2.6.30-r1
ACCEPT_KEYWORDS="x86"
ACCEPT_LICENSE="*"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-march=prescott -O2 -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /service /usr/inferno/keydb /usr/inferno/lib /usr/inferno/services /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/X11/xkb /usr/share/config /var/log /var/qmail/alias /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=prescott -O2 -pipe"
DISTDIR="/usr/portage-distfiles"
EMERGE_DEFAULT_OPTS="--with-bdeps=y"
FEATURES="assume-digests distlocks fixpackages news parallel-fetch protect-owned sandbox sfperms strict unmerge-logs unmerge-orphans userfetch userpriv usersandbox"
GENTOO_MIRRORS="ftp://ftp.df.lth.se/pub/gentoo/ http://ftp.df.lth.se/pub/gentoo/ http://gentoo.telcom.net.ua/"
LANG="ru_RU.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="en ru"
MAKEOPTS="-j3"
PKGDIR="/usr/portage-packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_EXTRA_OPTS="--exclude ChangeLog --delete-excluded"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/powerman /var/lib/layman/sunrise /var/lib/layman/kde-sunset /var/lib/layman/vmware /usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X Xaw3d a52 aac acl acpi aim alsa apache2 asf avi bash-completion berkdb bitmap-fonts bzip2 cddb cdr chm cli cracklib crypt cscope cue curl cxx dbus dga divx4linux djvu dlloader dri dts dvd dvdr dvdread encode fastcgi ffmpeg flac flash gd gdbm gif gnutls gpg gtk gtk2 hardened hddtemp iconv icq idn imagemagick imap imlib irc jabber javascript jpeg kde lm_sensors lzo mad mailbox mbox mmx mng modules motif mp3 mpeg msn mudflap musepack mysql ncurses nls nptl nptlonly ogg opengl openmp oss pam pcre perl pic png pppd pwdb python qt qt3support qt4 quicktime readline rss rtc samba sdl session spell sse sse2 ssl ssse3 svg sysfs tcltk tcpd theora tiff truetype truetype-fonts type1-fonts unicode urandom vim-pager vim-syntax vim-with-x vorbis wavpack win32codecs x86 xinetd xorg xv xvid yahoo zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 	emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m 	maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="     log_config vhost_alias     autoindex alias rewrite dir deflate filter mime negotiation     auth_basic authn_file authz_host authz_user authz_groupfile     cgi actions headers env setenvif     " COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en ru" LIRC_DEVICES="serial" PHP_TARGETS="php5-2" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="vesa fbdev nv nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" 
Unset:  CPPFLAGS, CTARGET, FFLAGS, INSTALL_MASK, LC_ALL, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS
Comment 1 Alex Efros 2010-11-04 16:27:36 UTC
I've just tried also dev-java/sun-jdk-1.6.0.22.

To emerge it I had to patch sun-jdk-1.6.0.22.ebuild:
- "${S}"/bin/java -server -Xshare:dump || die
+ "${S}"/bin/java -server -Xmx256m -Xshare:dump || die

To use it I had to edit /opt/sun-jdk-1.6.0.22/jre/lib/i386/jvm.cfg to force client VM:
--client IF_SERVER_CLASS -server
--server KNOWN
+-client KNOWN

This way ant-core (originally failed package) emerged successfully.

If anybody think I should open another bug for sun-jdk let me know.
Comment 2 Wormo (RETIRED) gentoo-dev 2010-11-12 20:29:22 UTC
I think it would be worth opening another bug for sun-jdk, thanks.

Assigning this one to java team to take a look.
Comment 3 Alex Efros 2011-03-07 13:49:05 UTC
Keeping in mind only option to have java working is fixing jvm.cfg, I think it worth adding CONFIG_PROTECT="/opt/icedtea6-bin-1.9.7/jre/lib/i386/jvm.cfg" to some file in /etc/env.d/ in this ebuild.

Bad thing is this file located in "icedtea6-bin-1.9.7" directory, i.e. CONFIG_PROTECT helps while re-emerging same package version but installing another version result in losing config changes. Probably this file should be moved to /etc/.

BTW, google search for "Could not reserve enough space for object heap" return many results, but no solutions. This issue is same for both icedtea6 and sun-jdk and happens on machines with 4GB+ RAM because both javas try to run as -server on such systems. Looks like both upstreams aware about issue, but there no fix yet. First workaround with adding "-Xmx" option doesn't really useful, because this issue happens while emerging packages (like ant or cmake) when we can't control java options. Second workaround with editing jvm.cfg not really useful until there will be way to protect changes in this config.
Comment 4 Ralph Sennhauser (RETIRED) gentoo-dev 2011-11-29 16:32:45 UTC
Even so this one is older the other one is more informative.

*** This bug has been marked as a duplicate of bug 389751 ***