Re: malloc was optimized out
Re: malloc was optimized out
- Subject: Re: malloc was optimized out
- From: Steve Sisak <email@hidden>
- Date: Tue, 05 Jul 2016 12:26:49 -0400
On Jul 5, 2016, at 2:27 AM, Jens Alfke <email@hidden> wrote:
If you absolutely need to preflight a huge memory allocation, I suggest creating a temporary file, resizing it to the desired size by setting its EOF, then using mmap to map the file into address space. (You should then unlink the file, ensuring it’ll be cleaned up when your process exits.)
I was going to suggest the same thing.
Basically, do your own VM if the allocation is over some threshold, say 25% or 50% of physical RAM.
This will fail when you resize the file and won’t compete with the system’s VM. If the resize succeeds, you’re good to go.
If your customer is on a SAN with 250GB free it will work — also it gives you the option of backing your huge allocations on a different drive (or drives) than the system VM.
HTH,
-Steve
|
_______________________________________________
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