From owner-freebsd-java@FreeBSD.ORG Mon May 24 00:58:20 2004 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BCB8816A4CE for ; Mon, 24 May 2004 00:58:20 -0700 (PDT) Received: from ulysses.noc.ntua.gr (ulysses.noc.ntua.gr [147.102.222.230]) by mx1.FreeBSD.org (Postfix) with ESMTP id A849043D31 for ; Mon, 24 May 2004 00:58:19 -0700 (PDT) (envelope-from past@noc.ntua.gr) Received: from ajax.noc.ntua.gr (ajax.noc.ntua.gr [147.102.220.1]) by ulysses.noc.ntua.gr (8.12.9p1/8.12.9) with ESMTP id i4O7vTRu020045; Mon, 24 May 2004 10:57:29 +0300 (EEST) (envelope-from past@noc.ntua.gr) Received: from [147.102.220.45] (hal.noc.ntua.gr [147.102.220.45]) by ajax.noc.ntua.gr (8.12.11/8.12.11) with ESMTP id i4O7vRgD020898; Mon, 24 May 2004 10:57:28 +0300 (EEST) (envelope-from past@noc.ntua.gr) Message-ID: <40B1AAE7.4020903@noc.ntua.gr> Date: Mon, 24 May 2004 10:57:27 +0300 From: Panagiotis Astithas Organization: NTUA/NMC User-Agent: Mozilla Thunderbird 0.6 (X11/20040510) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Greg Lewis References: <09BFCAF4-952D-11D8-822D-000393BB3E22@aps.org> <20040522174956.GA61678@misty.eyesbeyond.com> In-Reply-To: <20040522174956.GA61678@misty.eyesbeyond.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: Paul Dlug cc: freebsd-java@freebsd.org Subject: Re: Heap size limit X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 May 2004 07:58:20 -0000 Greg Lewis wrote: > On Fri, Apr 23, 2004 at 09:49:27AM -0400, Paul Dlug wrote: > >>I'm trying to start a JVM with a large heap size and getting an error >>message: >> >>java -Xms256m -Xmx2024m >>Error occurred during initialization of VM >>Could not reserve enough space for object heap >> >>I tried a bunch of different sizes and anything under 2024m works just >>fine so this appears to be a hard limit. I've tried changing a few >>system parameters but can't seem to stumble on the right one. Can >>someone help me out with this? > > > Obviously I'm a long way behind on freebsd-java, but I'm catching up now... > > My strong suggestion is that you're hitting the maximum amount of memory > that your user can mmap. I'm not exactly sure what setting dictate that, > but its almost certainly what you're running into. Definitely: ktrace java -Xms256m -Xmx2024m [...] 15034 java CALL mmap(0,0x82800000,0,0x1042,0xffffffff,0,0,0) 15034 java RET mmap -1 errno 22 Invalid argument 15034 java CALL write(0x1,0xbfbfd670,0x2b) 15034 java GIO fd 1 wrote 43 bytes "Error occurred during initialization of VM " 15034 java RET write 43/0x2b 15034 java CALL write(0x1,0xbfbfd670,0x2e) 15034 java GIO fd 1 wrote 46 bytes "Could not reserve enough space for object heap" [...] % grep 22 /usr/include/errno.h #define EINVAL 22 /* Invalid argument */ %man mmap [...] [EINVAL] MAP_FIXED was specified and the addr argument was not page aligned, or part of the desired address space resides out of the valid address space for a user process. [...] Now try changing vm.max_proc_mmap to an insanely large value: # sysctl vm.max_proc_mmap=10000000000000 vm.max_proc_mmap: 26960 -> 2147483647 We see the requested size gets truncated to 2 GB. This still doesn't help us, though: # /usr/local/jdk1.4.2/bin/java -Xms256m -Xmx2024m Error occurred during initialization of VM Could not reserve enough space for object heap The weird thing is that in a GENERIC kernel, the kernel/userland address space split is 1 GB / 3 GB. As it can bee sen from the following excerpt from /sys/i386/conf/NOTES: # # Change the size of the kernel virtual address space. Due to # constraints in loader(8) on i386, this must be a multiple of 4. # 256 = 1 GB of kernel address space. Increasing this also causes # a reduction of the address space in user processes. 512 splits # the 4GB cpu address space in half (2GB user, 2GB kernel). # options KVA_PAGES=260 Why you can't mmap up to 3 GB of memory, I don't know. Perhaps we should take it to -current or -hackers. Cheers, -- Panagiotis Astithas Electrical & Computer Engineer, PhD Network Management Center National Technical University of Athens, Greece