Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 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.

like image 359
Andrew Avatar asked Jul 03 '11 18:07

Andrew


3 Answers

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

like image 141
David Grayson Avatar answered Nov 17 '22 00:11

David Grayson


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

like image 24
fredoverflow Avatar answered Nov 16 '22 23:11

fredoverflow


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.

like image 2
Peter Alexander Avatar answered Nov 17 '22 00:11

Peter Alexander