Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Muncher

macrumors 65816
Original poster
Apr 19, 2007
1,465
0
California
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

macrumors 68040
Apr 22, 2005
3,531
2
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

macrumors 65816
Original poster
Apr 19, 2007
1,465
0
California
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.
 

Muncher

macrumors 65816
Original poster
Apr 19, 2007
1,465
0
California
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

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
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

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.