On 23 Oct 2012, at 11:21, Ulf Dunkel <dun...@calamus.net> 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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to