I have a texture-heavy OpenGL game that I\'d like to tune based on how much RAM the device has. The highest resolution textures I have work fine on an iPhone 4 or iPad2, but
Total physical RAM is available via sysctl(), as documented in this blog post and implemented as a nice clean API here (see the implementation of totalMemory in the corresponding .m file).
I've lifted the blog's code for convenience and posterity:
#include
size_t phys_mem()
{
int mib[] = { CTL_HW, HW_PHYSMEM };
size_t mem;
size_t len = sizeof(mem);
sysctl(mib, 2, &mem, &len, NULL, 0);
return mem;
}
I don't know if Apple will approve an app that uses sysctl() in this manner. It is documented, but only for Mac OS X.