• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Xcode 4.3.1 memory usage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Xcode 4.3.1 memory usage


  • Subject: Re: Xcode 4.3.1 memory usage
  • From: Jens Alfke <email@hidden>
  • Date: Fri, 16 Mar 2012 16:02:02 -0700


On Mar 16, 2012, at 3:31 PM, email@hidden wrote:

This one 4039 line file is the source of the trouble:
https://github.com/pmougin/F-Script/blob/master/FScriptFramework/FSObjectBrowserViewObjectInfo.m

clang Real Memory memory usage hits 4 to 5 GB when compiling this one file over a period of some 15 minutes or so.
If the build is cancelled before compilation completes then subsequent builds fail with a linker error:

That source file contains a pathologically long method named -fillMatrix:withObject:. It’s over 3000 lines long! Huge functions like this have always presented problems for code optimizers — I’m not an expert on compiler techniques, but I believe there are data structures and algorithms used in optimization that tend to grow as at least O(n^2) with the number of basic blocks or branches in the function being optimized.

As a result, code like this very often causes compilation to take a very long time, or use huge amounts of memory, or both. I’ve seen this in lots of projects over the years.

The lesson is Don’t Write Huge Functions. Besides giving compilers fits, they’re also very difficult to read and understand. A function that long nearly always should be broken up into lots of smaller functions. The only exceptions I’ve seen are intensely performance-critical functions like the inner loops of interpreters, but this doesn’t look like one of those. It just looks really badly written. :-p

—Jens
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Xcode 4.3.1 memory usage
      • From: email@hidden
    • Re: Xcode 4.3.1 memory usage
      • From: "email@hidden" <email@hidden>
References: 
 >Re: Xcode 4.3.1 memory usage (From: Brad Oliver <email@hidden>)
 >Re: Xcode 4.3.1 memory usage (From: Sean McBride <email@hidden>)
 >Re: Xcode 4.3.1 memory usage (From: Brad Oliver <email@hidden>)
 >Re: Xcode 4.3.1 memory usage (From: Sean McBride <email@hidden>)
 >Re: Xcode 4.3.1 memory usage (From: "email@hidden" <email@hidden>)

  • Prev by Date: Re: Xcode 4.3.1 memory usage
  • Next by Date: Source Control
  • Previous by thread: Re: Xcode 4.3.1 memory usage
  • Next by thread: Re: Xcode 4.3.1 memory usage
  • Index(es):
    • Date
    • Thread