From owner-freebsd-current@FreeBSD.ORG Fri Jun 18 16:06:06 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8AEC216A4CE for ; Fri, 18 Jun 2004 16:06:06 +0000 (GMT) Received: from mail2.ridge.aps.org (mail2.ridge.aps.org [149.28.9.33]) by mx1.FreeBSD.org (Postfix) with ESMTP id 30B8843D1F for ; Fri, 18 Jun 2004 16:06:06 +0000 (GMT) (envelope-from paul@aps.org) Received: from [149.28.3.185] (jaguar.aps.org [149.28.3.185]) by mail2.ridge.aps.org (8.12.9/8.12.9) with ESMTP id i5IG5D4p057561; Fri, 18 Jun 2004 12:05:13 -0400 (EDT) (envelope-from paul@aps.org) Mime-Version: 1.0 (Apple Message framework v618) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <487C4BD2-C141-11D8-9D52-000393BB3E22@aps.org> Content-Transfer-Encoding: 7bit From: Paul Dlug Date: Fri, 18 Jun 2004 12:05:14 -0400 To: freebsd-current@freebsd.org X-Mailer: Apple Mail (2.618) X-Spam-Score: -4.901 () BAYES_00 X-Scanned-By: MIMEDefang 2.38 cc: Panagiotis Astithas Subject: Heap size limit in java X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jun 2004 16:06:06 -0000 I originally posed to my question to freebsd-java. My issue was that I was unable to set a java heap size of more than approx 2000m using java (-Xmx2000m), it would fail with the error "COuld not reserve enough space for object heap. Panagiotis Astithas looked into this a bit further and found that it was due to the JVM being unable to mmap 3gb or more of memory. His explanation is below along with some of the background information. Any help would be greatly appreciated. I imagine others have hit this issue or will shortly. It's somewhat critical to getting large scale java applications running on FreeBSD that the JVM be able to access enough memory. Thanks, Paul From: Panagiotis Astithas Date: May 24, 2004 3:57:27 AM EDT To: Greg Lewis Cc: Paul Dlug , freebsd-java@freebsd.org Subject: Re: Heap size limit 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