开发者

How to figure out which methods increases size of 'exe'

开发者 https://www.devze.com 2023-03-16 20:45 出处:网络
I\'m trying to write my first \'demoscene\' application in MS Visual Studio Express 2010. Suddenly I realized, that my binary expanded from 16kb to ~100kb in fully-optimized-for-size开发者_StackOverfl

I'm trying to write my first 'demoscene' application in MS Visual Studio Express 2010. Suddenly I realized, that my binary expanded from 16kb to ~100kb in fully-optimized-for-size开发者_StackOverflow release version. My target size is 64k. Is there any way to somehow "browse" binary to figure out, which methods consumes a lot of space, and which I should rewrite? I really want to know what my binary consists of.

From what I found in web, VS2010 is not the best compiler for demoscenes, but I still want to understand what's happening inside my .exe file.


I think you should have MSVC generate a map file for you. This is a file that will tell you the addresses of most of the different functions in your executable. The difference between consecutive addresses should tell you how much space the function takes. To generate a map file, add the /MAP linker option. For more info, see: http://msdn.microsoft.com/en-us/library/k7xkk3e2(v=VS.100).aspx


You can strip off lots of unnecessary stuff from the executable and compress it with utilities such as mew.


I've found this useful for examining executable sizes (although not for demoscene type things): http://aras-p.info/projSizer.html

I will say this: if you are using the standard library at all then stop immediately. It is a huge code bloater. For example, each unique usage std::sort adds around 5KB and there's similar numbers for many of the standard containers (of course, it depends what functions you use, but in general they add lots of code).

Also, I'm not into the demo scene, but I believe people use Crinkler to compress their executables.


Use your version contol system to see what caused the increase. Going forward, Id log the built exe size during the nightly builds. And dont forget you can optimize for minimal size with the compiler settings.

0

精彩评论

暂无评论...
验证码 换一张
取 消