• 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: Memory issues when loading a document
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory issues when loading a document


  • Subject: Re: Memory issues when loading a document
  • From: Mike Abdullah <email@hidden>
  • Date: Tue, 23 Oct 2012 11:57:09 +0100

On 23 Oct 2012, at 11:21, Ulf Dunkel <email@hidden> wrote:

> I wonder if this issue is created by our app or if it is inherent in Mac
> OS X:
>
> Our app creates documents which can contain various content per document
> page, e.g. PDF files. Assume you have created a document with 64 pages,
> each of them contains a full-page PDF content. The document file's
> "weight" is about 1 GB when it is saved.
>
> When users try to reload the document on a Mac with 4 GB RAM, it cannot
> be opened, because of a lack of memory.

Important bit you haven't told us: is your app 32bit, 64bit, or both?

> Tracking the allocations with
> Instruments, I can see strange things happen:
>
> - The app itself consumes about 300 MB RAM.
> - The document is loaded in several steps, where the first step
> allocates the document size with -[NSData(NSData) initWithContentsOfFile:].
> - Then the RAM for page content files (the PDFs) is allocated and the
> relevant PDF is being loaded - but:
>
> - The first PDF load process allocates additional RAM for the first PDF.
> - The 2nd PDF allocates additional RAM for the 1st and 2nd PDF.
> - The 3rd PDF allocates additional RAM for the 1.-3. PDF.
> - Etc.
>
> So this procedure sums up to about 3.5 GB RAM which of course is
> followed by an exception.
>
> On bigger machines, the additional RAM for the PDFs is deallocated after
> the document has been loaded successfully.
>
> Is this a wanted behavior of Mac OS X, or are we able to control how
> much RAM is being allocated in the document load process?

You have very fine-grained control available to you. Read up on the document architecture and the different NSDocument methods you can override.


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Memory issues when loading a document
      • From: Ulf Dunkel <email@hidden>
References: 
 >Memory issues when loading a document (From: Ulf Dunkel <email@hidden>)

  • Prev by Date: Memory issues when loading a document
  • Next by Date: sync drawing an ever-increasing path
  • Previous by thread: Memory issues when loading a document
  • Next by thread: Re: Memory issues when loading a document
  • Index(es):
    • Date
    • Thread