App File Size

I’ve been taking a closer look at file size as I approach the finish line and ready my app for submission. My app is a bit larger than I expected and it seems that at least some of this can be attributed to the fact that building a bare OF project with nothing going on seems to run around 6 MB and change.

Is there anything we can do to reduce the file size of our apps? I’m only using OF for vector drawing and ofImage, so I hate that I might have to drop certain assets to stay under the 20MB 3G limit as a consequence of choosing OF for its great drawing capabilities.


How are you measuring the file size - are you using Instruments to measure the All Allocations value?

I’m checking the file size of the .app file in my build directory.

I had an app (a non-OF one) which was 20MB allocated memory to begin with. It used lots of full screen png images which were overlaid on top of each other. I got the memory usage down to 2MB by consolidating some images together and also cropping lots of images to the smallest I needed. So, do check the size of the images you are loading with ofImage. Definitely worth running Instruments on your app though to see how much of that static memory footprint actually gets loaded when run.

Sorry, I should have been more clear. I’m not worried about my memory usage, which seems to be fine. I AM worried about the file size of my final app. If it goes above 20MB people will have to download it over Wi-Fi, which I imagine will impact # of downloaders drastically.

The base iPhone Example app seems to run about 6MB so I’m wondering if there’s anything to do to cut that size down, as it only leaves 14MB to play with (easily filled by MP3s and artwork.)

I just checked the file size of my OF apps and my main app is about 5MB, but some out-of-the-box OF example apps - touchAndAccelExample and guiExample - are just 1.1MB each…


I also noticed that the simulator build was way bigger than the device build…

Don’t have any solution, but if your example apps are too large already, maybe there’s some build setting responsible for it, rather than the actual code…

E.g. what filesize do you get for touchAndAccelExample and guiExample (debug config, target=device)?

touchAccel is 1.8MB, and guiExample is 1.1…

I’ve dug around a little bit and there’s a few things I’ve been able to do to get my file size down.

  1. Export a clean directory from SVN and build that. It seems like some of the backups in the .svn folder in /bin/data are being included in the build so this chops off a few MB.

  2. Use the “fastest, smallest” GCC optimization for my target’s build preferences.

  3. Like you said, device builds tend to run smaller. I think this has to do with the version of libFreeImage that’s being used for a device build rather than a simulator build.

That said, my base file size without code (resources only) is about 4.8MB. After the code is compiled, the size is 8.4MB. Where are the other 3.6MB coming from? Is it possible that my code is this large?

Looking at the “code” column in my details view shows a bunch of ~400K compiled source files. Is there anything I can do to get the size down further? The only additional frameworks I’ve included besides the ones in the examples above are AVFoundation.framework and ofxBox2d.

It’s also worth mentioning that the debug and release configurations both give me file sizes about 1.5MB larger than the debug configuration.

Ok… in the absence of expert opinion here… I’ll just post my findings too :?

Switching from debug to release config for me took the app file size from 5.8 to 5.1 MB. Hard to believe that I have 700KB of debug stuff in there, but there it is…

That said, my base file size without code (resources only) is about 4.8MB. After the code is compiled, the size is 8.4MB. Where are the other 3.6MB coming from? Is it possible that my code is this large?

…that’s interesting: mine’s the other way around: 5.5MB of resources, 500KB of code builds to a 5.1MB release app file size…

Another thing to check is any ttc font files you have there… they can be a MB or two each…

Keep us posted with your findings!

I believe I’ve figured this out.

Some figures:

Release build from trunk

Release build from trunk after a clean SVN export

Checked “Deployment Postprocessing”, “Strip Debug Symbols During Copy”, “Strip Linked Product”, “Use Separate Strip”, UN-checked "Generate Debug Symbols"

Used libFreeImage_iphone_universal.a that comes with OF 0061 instead of the one found in the “DWARF errors” post

At this point I’ve got a “fat” executable containing both armv6 and armv7 versions. If I check “Build Only Active Architecture”, that gets my file size down to 6.8MB, at the cost of only having an armv6 version. I’ll have to run some benchmarks to decide whether I’d rather have a 4MB executable that runs faster on newer devices or a 2MB executable that might not be quite as optimized on the new devices. This would indicate that the final size of the application is around 2MB in code after we’ve subtracted the data directory (which runs around 4.8MB), which I’m willing to accept considering I’ve added additional frameworks and written a good portion of my own code outside of what’s in those examples.

So a few simple tweaks in my build settings and an issue with SVN brings my file size to nearly a third of what it was at first. I’m going to keep poking around and see if there’s anything else I can do to bring down file size but hopefully this information is useful to someone else. It really caught me off guard.

Thanks! That is useful info - I’m using SVN too - good catch…