Is there a “function size profiler” out there?

后端 未结 5 1079
时光说笑
时光说笑 2021-01-31 21:40

After three years working on a C++ project, the executable has grown to 4 MB. I\'d like to see where all this space is going. Is there a tool that could report what the biggest

5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-31 22:05

    Get a link map, or use dumpbin to get a list of symbols and sizes.

    Chances are there's a lot of stuff being pulled in that you don't strictly need.

    ADDED: Did you get a satisfactory answer? I realized there are two ways people approach problems like this:

    • Get measurements before they do anything.
    • Just find something big that they don't need, rip it out, and repeat until they can't.

    Personally I prefer the latter - it gets results quicker.

    You say the app is 4MB. Suppose the true necessary size is 1MB (or some such size). That means if you pick a routine at random from the map file, it is 75% likely to be something you don't need. Find out what's causing it to be included, and see if you really need it.

    In the example you gave, you saw a class that wraps device-independent-bitmaps. You could find instances of that class in your app, and possibly replace them with basic WIN32 bitmaps. It would be less pretty, but save gobs of app size.

    Then keep on doing it. Each large piece you get rid of makes the remaining pieces take a larger percentage of the app, because the app has shrunk but the pieces haven't. That makes them easier to find in the map file.

提交回复
热议问题