Why are beam files so large?
Joe Armstrong
joe@REDACTED
Thu Dec 7 10:52:27 CET 2000
> A BEAM file now contains several structured sections. You can run
> erlc like
>
> % erlc +compressed +no_debug_info ........
>
> to get them alot smaller. There are still sections left that
> can be removed, I don't know how. Check out the sections and
> the sizes with
>
> 1> beam_lib:info("foo.beam").
> [{file,"foo.beam"},
> {module,foo},
> {chunks,[{"Atom",20,67},
> {"Code",96,181},
> {"StrT",288,31},
> {"ImpT",328,28},
> {"ExpT",364,52},
> {"LocT",424,4},
> {"Attr",436,81},
> {"CInf",528,202},
> {"Abst",740,492}]}]
>
> kent
>
This is very interesting ....
Pretty nifty: Lets give it a whirl:
> erlc packer.crl
> ls -l packer.beam
-rw-r--r-- 1 joe staff 1868 Dec 7 09:41
1> beam_lib:info("backer.beam").
[{file,"packer.beam"},
{module,packer},
{chunks,[{"Atom",20,210},
{"Code",240,354},
{"StrT",604,47},
{"ImpT",660,136},
{"ExpT",804,52},
{"LocT",864,28},
{"Attr",900,40},
{"CInf",948,180},
{"Abst",1136,729}]}]
So far so good
> erlc +compressed +no_debug_info packer.erl
> ls -l packer.beam
-rw-r--r-- 1 joe staff 830 Dec 7 09:42
Wow - a lot smaller, but ...
>erl
Erlang (BEAM) emulator version 5.0.1.1 [source]
Eshell V5.0.1.1 (abort with ^G)
1> beam_lib:info("packer.beam").
{error,beam_lib,{missing_chunk,"packer.beam","FOR1"}}
Questions:
1) How can I do the +compressed etc. stuff from Erlang i.e. not the shell
compile:file("foo", [compressed]).
Didn't work
2) Can I write "strip" that takes a module compiled with default
options and away debug info and compresses the results ???
/Joe
--
Joe Armstrong,
Alteon WebSystems, tel: +46 8-545 550 00
S:t Eriksgatan 44, IV, fax: +46 8-545 550 50
SE-112 32 Stockholm, Sweden info: www.bluetail.com
More information about the erlang-questions
mailing list