• 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: Get current amount of available RAM
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get current amount of available RAM


  • Subject: Re: Get current amount of available RAM
  • From: Jason Coco <email@hidden>
  • Date: Thu, 28 Aug 2008 01:09:28 -0400


On Aug 28, 2008, at 00:31 , Alex Kac wrote:

I need to check for free RAM before performing a specific operation. I've Googled and checked in the docs and I suspect its my terminology that's just out of whack.

So what is the best way to find out how much available RAM is available in a Cocoa app?

You can also get some information with these calls, although I don't know how useful it will be in your situation:


// Amount of physical memory installed -- requires 10.5
unsigned long long memory = [[NSProcessInfo processInfo] physicalMemory];


// Amount of memory allocated to user space
unsigned long long memory;
size_t mem_len = sizeof(memory);
int mib[2];

mib[0] = CTL_HW;
mib[1] = HW_USERMEM;
if( sysctl(mib, 2, &memory, &mem_len, NULL, 0) == -1 ) {
 perror("sysctl");
}

It doesn't really tell you about what's actually available to the application, though :/

J

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

References: 
 >Get current amount of available RAM (From: Alex Kac <email@hidden>)

  • Prev by Date: Re: Layer-Backed Views, Mouse, Presentation Tree Bug?
  • Next by Date: Re: Get current amount of available RAM
  • Previous by thread: Re: Get current amount of available RAM
  • Next by thread: Layer-Backed Views, Mouse, Presentation Tree Bug?
  • Index(es):
    • Date
    • Thread