0

When building applications, especially when using static linking and having a lot of dependences, I often feel that most of this 50-megabyte executable is just unused bloat, especially if consider only the mode I want.

Is there something that lets you run the program in various scenarious, collect data and build the program again (or tinker already compiled code) to remove the unvisited code (replacing things with abort)? If yes, how is it correctly called and where is it implemented?

Vi.
  • 37,014
  • 18
  • 93
  • 148
  • I'm not aware of such a tool. Utilizing something like that would require a test suite with 100 percent code coverage, which is quite difficult to achieve for non-trivial code bases. – 500 - Internal Server Error Sep 14 '16 at 23:10
  • I know that the Eclipse IDE shows you the code which is not used, maybe you might consider verifying the IDE you're working with. – Dominique Sep 15 '16 at 13:42

1 Answers1

0

I'm perfectly willing to use techniques, rather than tools. What I've done for your problem is get a map file and just look through it. There may well be a lot of methods for classes you doubt you need. Find out what references put them in there. Chances are it's just because somewhere something fancy was coded, like a bells-and-whistles container class, when something simple would do. Or a whole math library when all you needed was max.

After fixing that, the map file is smaller, and something else is the biggest thing in it, so you can do it all again.
And again...

This can cut out gobs of bloated binary.

Mike Dunlavey
  • 40,059
  • 14
  • 91
  • 135