[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freebsd-java
Subject:    patch: autoadjust datasegment size
From:       "Arne H. Juul" <arnej () pvv ! ntnu ! no>
Date:       2007-02-22 20:53:25
Message-ID: Pine.LNX.4.62.0702222145380.11020 () decibel ! pvv ! ntnu ! no
[Download RAW message or body]

We're running in an environment where the default datasegment size is 
often adjusted upwards to provide more address space for applications that 
allocate a lot of memory, but this causes the Java VM to fail during 
startup since the Java heap is allocated outside the data segment by using 
mmap().  I've been compiling with a patch (below) that auto-adjusts the 
datasegment down to a "reasonable" value.

I don't know enough about the details of the VM system of the various BSDs 
to be certain that this is generally applicable, but my guess is that this 
will be useful on all 32-bit BSDs.

  -  Arne H. J.

diff -ru jdk-1_5_0_11.b4/hotspot/src/os/bsd/vm/os_bsd.cpp \
                jdk-1_5_0_11.ahj12/hotspot/src/os/bsd/vm/os_bsd.cpp
--- jdk-1_5_0_11.b4/hotspot/src/os/bsd/vm/os_bsd.cpp	Sun Feb 18 16:13:42 2007
+++ jdk-1_5_0_11.ahj12/hotspot/src/os/bsd/vm/os_bsd.cpp	Tue Feb 20 22:29:27 2007
@@ -2706,7 +2833,30 @@

  // this is called _after_ the global arguments have been parsed
  jint os::init_2(void) {
- 
+
+  // XXX ugly hack for 32-bit address space, since we know the
+  // java heap is allocated with mmap() not sbrk():
+#if SSIZE_MAX == 0x7fffffff
+  // set the max datasegment size to something reasonable
+  // complain if getrlimit/setrlimit fails but continue regardless. 
+  struct rlimit dseg_size;
+  int status = getrlimit(RLIMIT_DATA, &dseg_size);
+  if (status != 0) {
+     if (PrintMiscellaneous && (Verbose || WizardMode))
+        perror("os::init_2 getrlimit failed");
+  } else {
+     if (dseg_size.rlim_max > 1000 * 1024 * 1024) {
+        dseg_size.rlim_max = 500 * 1024 * 1024;
+        dseg_size.rlim_cur = 500 * 1024 * 1024;
+        status = setrlimit(RLIMIT_DATA, &dseg_size);
+        if (status != 0) {
+           if (PrintMiscellaneous && (Verbose || WizardMode))
+               perror("os::init_2 setrlimit failed");
+        }
+     }
+  }
+#endif
+
    // Allocate a single page and mark it as readable for safepoint polling
    if( SafepointPolling ) {
      address polling_page = (address) ::mmap(NULL, page_size,
_______________________________________________
freebsd-java@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "freebsd-java-unsubscribe@freebsd.org"


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic