Skip to main content
gamedev.net
🔒 Locked

executable size

Started by irreversible Jul 6, 2006 at 5:28 PM 8 replies 750+ views
Original Post
irreversible
irreversible
Is it normal that using fstream and select windows (lean and mean) function calls push the executable size up to the 130 kB region with size optimizations enabled? I have a few other classes of my own that take up roughly 8 kB (empirical tests showed that), but using an ifstream instance magically adds some 60-80 kB to the program size, even though I'm only using tellg(), seekg() and read(). This seems insane given that the program could be fit into ~5 kB without directly mapping all that unneccessary junk directly into the exe at link time. I'm using VC8, all optimizations geared towards favoring small code size. What's worse, UPX can't directly compress the executable for some reason, so I have to --force it, after which the file is half as large (~62 kB, still way too large), but just plain won't run: "The application failed to initialize properly (0xc0000005)" (displayed twice) The grand flop of all times, to me, is this:

void main(){}



links to 44 kB (again, with size optimizations enabled). Is that normal? I mean, I'd expect some 0.2 - 0.6 kB bytes at most... And yes, before anyone asks - I'm talking about release mode. PS - in this instance I'm talking about a Windows console application.
bytecoder
bytecoder
What compiler? Gcc is known to produce relatively large executables for small programs simply because it has to link the standard library in with the executable if you use it (IIRC). Keep in mind that the amount of junk it adds is constant--once your program starts getting bigger the extra stuff won't be very noticeable.
ShawMishrak
ShawMishrak
Are you linking against the DLL CRT ["Multithreaded DLL" in C/C++ Code Generation options] or Static CRT ["Multithreaded" in C/C++ Code Generation options]?

irreversible
irreversible
Quote:
Original post by ShawMishrak
Are you linking against the DLL CRT ["Multithreaded DLL" in C/C++ Code Generation options] or Static CRT ["Multithreaded" in C/C++ Code Generation options]?


Okay this is odd.

The default was on MT DLL, which seemed reasonable, but it produced the 130 kB version (which is why I went on a quest to find out what's up). Swithing to MT didn't help much (which sort of makes sense). But now that I switched back to MT DLL the code size cut down to ~10 kB.

Odd, I say. Odd.


bytecoder: the answer is in the OP, and yes I know that. At the moment I'm trying to create a very small sample application and 130 kB seems like people would laugh at me if I gave them that, that's all :)
raz0r
raz0r
If it's appropriate for your little demo, consider using assembly language. Probably only a good idea if you're only going to distribute the binary, though.
markr
markr
Don't worry about it - most of that size isn't caused by your code and hence the executable size will no go up linearly with the size of your source.

It's probably all C++ library / init stuff, which will remain constant in size even if your program becomes very large.

Mark
Aardvajk
Aardvajk
Yeah, I complained about this on GameDev once and got severely told off. The point made to me was that if my program is 100k, an extra 140k of library code seems like a lot, but on a proper size program, say a couple of meg at least, 140k seems pretty trivial.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.