Re: NSUserDefaults allocation size and CALayer memory usage
Re: NSUserDefaults allocation size and CALayer memory usage
- Subject: Re: NSUserDefaults allocation size and CALayer memory usage
- From: Jens Alfke <email@hidden>
- Date: Mon, 29 Jun 2015 09:27:10 -0700
> On Jun 28, 2015, at 11:35 PM, Henrik Granaas-Helmers <email@hidden> wrote:
>
> 1. NSUserDefaults seems to allocate 16 MB memory at load. I can't see myself using a megabyte—let alone 16 of those. It would be very interesting to know why it allocates so much, and if there is a way to encourage NSUserDefaults to grab less.
Probably you’re looking at the memory allocated by a lot of system components during app initialization, or of components that get initialized lazily during the first call to NSUserDefaults.
> 2. I create a couple of CoreAnimation layers that I think are large (5120x2880 px). I would expect that to occupy 450 MB (5120*2880*32/1024/1024) of memory. But instead it only takes up one fourth of that. What is this sorcery?
Much of that memory is likely allocated in the WindowServer’s address space, or even on the GPU.
General advice: Don’t micromanage your use of memory, and as with all optimization, wait until you have something working before trying to performance-tune.
And as Quincey said, in any modern OS it becomes very tricky to say how much memory is being used. It’s complicated by factors like virtual memory, paging, memory-mapped files, shared memory, copy-on-write, GPU vs CPU …
—Jens
_______________________________________________
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