How to reduce size of executable?
Jeff Sturm
jsturm@one-point.com
Thu Dec 12 09:44:00 GMT 2002
On 2002年12月11日, Sergiy Lozovsky wrote:
> I'm not going to make serious changes to GCJ. Having
> this in mind, do I have any chances to run JAVA/GCJ
> application at Linux device with 8M of RAM? (sure
> kernel will take a little bit more than 1M, some other
> stuff).
Maybe. Obviously it depends on the size of your application.
> What minimal size of HelloWorld can I expect.
With a little bit of hacking (on i686-linux) I get:
[jsturm@suzy tmp]$ ls -l hello
-rwxrwxr-x 1 jsturm jsturm 997988 Dec 12 12:21 hello
[jsturm@suzy tmp]$ size hello
text data bss dec hex filename
741369 244800 111720 1097889 10c0a1 hello
[jsturm@suzy tmp]$ ldd hello
libgcc_s.so.1 => /opt/gcc/lib/libgcc_s.so.1 (0x40029000)
libm.so.6 => /lib/i686/libm.so.6 (0x40031000)
libpthread.so.0 => /lib/i686/libpthread.so.0 (0x40054000)
libdl.so.2 => /lib/libdl.so.2 (0x40069000)
libc.so.6 => /lib/i686/libc.so.6 (0x4006d000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
[jsturm@suzy tmp]$ ./hello
Hello World
This image contains exactly 219 classes. The bytecode interpreter and
JNI are disabled. Overall VM footprint is around 5MB, but much of that
isn't mapped and consists of locale data, etc.:
VmSize: 5516 kB
VmLck: 0 kB
VmRSS: 1928 kB
VmData: 2620 kB
VmStk: 20 kB
VmExe: 728 kB
VmLib: 1580 kB
I'd guess that with a less-bloated libc (i.e. newlib) you could cut
the memory footprint about in half.
Jeff
More information about the Java
mailing list