PDA

View Full Version : SDL app file size




Muncher
Mar 18, 2008, 11:05 PM
I recently made a demo of a water-sim in C with SDL. When I compiled the program, removed unnecessary files, and ran it through xslimmer, i still had a 28KB app. I realize 4KB comes from info.plist, but why does 7KB of code take 24KB of space?! Can I reduce this any further?

The reason I'm so obsessive about space comes from the time I've spent programming for microcontrollers. Also, I might try to make a 64kb intro for mac (not a port!) if I can get these apps smaller.



admanimal
Mar 18, 2008, 11:30 PM
Have you actually opened up the .app bundle and looked at what is inside? There are a number of other files that could be in there taking up space.

Muncher
Mar 19, 2008, 09:15 AM
Have you actually opened up the .app bundle and looked at what is inside? There are a number of other files that could be in there taking up space.

Yeah, the SDL library takes up almost 1.5MB, and then there are other unused files.

iSee
Mar 19, 2008, 10:58 AM
I don't know, but here's the mach-o file format reference:

http://developer.apple.com/documentation/DeveloperTools/Conceptual/MachORuntime/Reference/reference.html

Knock yourself out!

Maybe someone has created a high-level mach-o format browser. If not, maybe it will be easy enough to analyze your simple app with just a hex editor and the reference.

sord
Mar 19, 2008, 05:15 PM
24KB, or 24MB?

Muncher
Mar 19, 2008, 10:14 PM
24KB, or 24MB?

kilobytes. I know, I know, modern computers and all that. I want a 10K file max, and for how much I wrote, that's not asking much.

Muncher
Mar 26, 2008, 09:04 PM
Hah, I finally got it. I am using iPakk, a command-line tool for packing executables, and I'm not using SDL anymore, but OGL directly, which cuts down on usage. I got everything down to under 8Kb, and the compression ratio will probably get better as I add more stuff to it.

lee1210
Mar 26, 2008, 09:36 PM
In another thread we were working on an assembly hello world program. The object file was 364 bytes. 137 of them were non-null. Once it was linked, the resulting file was 8248 bytes. 236 of them were non-null. As was recommended above, hacking on the mach-o format is probably going to be your only way to go. If printing "Hello World!" and returning 0 takes 8248 bytes after linking, you only have 1992 bytes left to play with to do anything useful without playing with the format of the binary yourself. There may be a "cheaper" linker that will optimize for you, but I'm not familiar with anything like that.

Edit: Too slow, looks like you found something to do the hard hacking for you.

lee1210
Mar 26, 2008, 09:44 PM
I am admittedly unfamiliar with executable packing, but this did trim the hello world program down to 3071 bytes, 2414 of which were non-null. Certainly interesting. At least you have some extra bytes to play with now, good luck.

-Lee