Opened 12 years ago

Closed 12 years ago

#11143 closed defect (fixed)

executable files are too big

Reported by: pitti13 Owned by:
Priority: normal Milestone:
Component: base Version: stable-latest
Keywords: large-executable-size Cc:
Blocked By: Blocking:
Patch: yes

Description

I was wondering why a simple console program (wxrc.exe) ended up with a size of 2.5MB. After playing with compiler settings (optimize for size, whole program optimization, COMDAT folding, function level linking, LTCG, string pooling, etc.), I was able to reduce it to 1.6MB, which was still way too much, as wxrc.exe, compiled with wx2.8, only used to be 350KB in size.

Looking at the executable, I saw that half of the file consisted of null bytes. I compiled with a map file and found out that something in datetime.cpp uses up a lot of space:

 0003:0000086c       ??_R0?AVwxDateTimeWorkDays@@@8 0048386c     wxmsw29u_base:datetime.obj
 0003:0011deb0       ??_R0?AVwxStringTokenizer@@@8 005a0eb0     wxmsw29u_base:tokenzr.obj

(Note the jump in the offset from 0x86c to 0x11deb0)...

When I looked at datetime.cpp, I soon found the culprit:

    static const char *weekdayNames[2][DAYS_PER_400_YEARS] =

With DAYS_PER_400_YEARS being a pretty large number, this allocates a lot of unused non-BSS space in the executable...

The patch fixes the line by changing that to DAYS_PER_WEEK.

Attachments (1)

wxWidgets_reduce_exe_by_1MB.diff download (525 bytes) - added by pitti13 12 years ago.

Download all attachments as: .zip

Change History (3)

Changed 12 years ago by pitti13

comment:1 Changed 12 years ago by vadz

  • Keywords large-executable-size added; large executable size removed

Thanks a lot for finding this embarrassing bug!

comment:2 Changed 12 years ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [61765]) Use correct array size for weekday names.

DAYS_PER_400_YEARS was erroneously used instead of DAYS_PER_WEEK which
resulted in creation of much larger object file than needed as the array is
initialized.

Closes #11143.

Note: See TracTickets for help on using tickets.