Hello,

In my build of OpenJDK 9 (updated from dev today), libjvm.so on linux x64 is 20902848B. It has been stripped using "strip -g" which means remove all debug symbols. It seems it can be reduced further to 17611752B using "strip --strip-unneeded", but I don't know if that is safe to do.

By default we use static linking of libstdc++ for libjvm.so for maximum portability of the binaries. In the OpenJDK community it's common to configure dynamic linking. This slightly reduces size to 19908552B.

Note that we build using GCC on Linux and Clang on macosx. I'm guessing that's the biggest source of size differences.

/Erik

On 2016-11-26 15:51, Jola I Waldek wrote:

From: David Holmes <david.hol...@oracle.com>
Date: October 28, 2016 at 17:30:22 EDT
To: Waldek Kozaczuk <jwkozac...@gmail.com>, jigsaw-...@openjdk.java.net
Subject: Re: Size difference of Java.base image between OSX and Linux

On 29/10/2016 3:32 AM, Waldek Kozaczuk wrote:

I used jlink to create minimal custom JRE image on OSX and Linux and I noticed 
there is a significant difference in size. The Mac version takes 21M where the 
Linux one takes 30M which means Linux version is 50% bigger than Mac.

Is it as you would have expected? Why is size difference so big?

I noticed that lib/modules is similar in size (1M difference) but the biggest 
difference is between ./lib/server/libjvm.dylib (12 M) and 
./lib/amd64/server/libjvm.so (21 M). So the linux version of the shared library 
object is almost twice as big on linux (both 64 bit).
Nothing jlink related. This is a question for the build-dev and/or hotspot-dev 
folk. It seems that in 8u libjvm is <1MB larger on Linux than OSX. However in 9 
the Linux version has steadily grown to ~21M while the OSX version has shrunk to 
~12M. It may be related to the debugging/symbol info still present in the library.

David

Here is the command I used to create the image:
jdk-9/bin/jlink --module-path jdk-9/jmods --add-modules java.base --output 
image_target --strip-debug --compress=2

Here is a detailed listing of files on Mac:
68K    ./bin/java 68K    ./bin/keytool 8.0K    ./conf/net.properties 4.0K    
./conf/security/java.policy 40K    ./conf/security/java.security 4.0K    
./conf/security/policy/limited/default_local.policy 4.0K    
./conf/security/policy/limited/default_US_export.policy 4.0K    
./conf/security/policy/limited/exempt_local.policy 4.0K    
./conf/security/policy/README.txt 4.0K    
./conf/security/policy/unlimited/default_local.policy 4.0K    
./conf/security/policy/unlimited/default_US_export.policy 20K    
./include/classfile_constants.h 4.0K    ./include/darwin/jni_md.h 76K    
./include/jni.h 80K    ./include/jvmti.h 4.0K    ./include/jvmticmlr.h 68K    
./lib/jli/libjli.dylib 16K    ./lib/jspawnhelper 4.0K    ./lib/jvm.cfg 204K    
./lib/libjava.dylib 32K    ./lib/libjimage.dylib 12K    ./lib/libjsig.dylib 92K 
   ./lib/libnet.dylib 68K    ./lib/libnio.dylib 44K    
./lib/libosxsecurity.dylib 48K    ./lib/libverify.dylib 32K    
./lib/libzip.dylib 7.2M    ./lib/modules 4.0K    ./lib/security/blacklist 4.0K  
  ./lib/security/blacklisted.certs 112K    ./lib/security/cacerts 8.0K    
./lib/security/default.policy 0B    ./lib/security/trusted.libraries 12K    
./lib/server/libjsig.dylib 12M    ./lib/server/libjvm.dylib 4.0K    
./lib/server/Xusage.txt 104K    ./lib/tzdb.dat 4.0K    ./release

Here is a detailed listing of files on Linux:

4.0K    ./lib/security/blacklisted.certs
8.0K    ./lib/security/default.policy
4.0K    ./lib/security/blacklist
0    ./lib/security/trusted.libraries
104K    ./lib/tzdb.dat
12K    ./lib/jexec
4.0K    ./lib/amd64/jvm.cfg
108K    ./lib/amd64/libnet.so
72K    ./lib/amd64/jli/libjli.so
132K    ./lib/amd64/libjimage.so
220K    ./lib/amd64/libjava.so
36K    ./lib/amd64/libzip.so
21M    ./lib/amd64/server/libjvm.so
4.0K    ./lib/amd64/server/Xusage.txt
12K    ./lib/amd64/server/libjsig.so
88K    ./lib/amd64/libnio.so
12K    ./lib/amd64/libjsig.so
64K    ./lib/amd64/libverify.so
8.2M    ./lib/modules
4.0K    ./release
4.0K    ./include/jvmticmlr.h
4.0K    ./include/linux/jni_md.h
20K    ./include/classfile_constants.h
80K    ./include/jvmti.h
76K    ./include/jni.h
4.0K    ./conf/security/policy/limited/default_local.policy
4.0K    ./conf/security/policy/limited/default_US_export.policy
4.0K    ./conf/security/policy/limited/exempt_local.policy
4.0K    ./conf/security/policy/README.txt
4.0K    ./conf/security/policy/unlimited/default_local.policy
4.0K    ./conf/security/policy/unlimited/default_US_export.policy
40K    ./conf/security/java.security
4.0K    ./conf/security/java.policy
8.0K    ./conf/net.properties
12K    ./bin/java
12K    ./bin/keytool

Regards,
Waldek

Sent from my iPhone



Reply via email to