IPhone / iPad IOS App Instrument Memory Count vs. task_info Memory Count?

Those numbers cannot be compared really. Even pages belonging to a (shared) memory mapped file (e.g. A library) will count as resident pages for the task. But they will be ignored by the Leak Tester.

Those numbers cannot be compared really. Even pages belonging to a (shared) memory mapped file (e.g. A library) will count as resident pages for the task. But they will be ignored by the Leak Tester.

The important thing to note is that there is a conceptual difference between memory available to the process (in whatever way: readonly, read/write, executable or not) and memory allocated by you, within your program. Not all available memory is connected to an actual allocation you did (e.g. A shared library) and not all memory you allocate is necessarily resident in memory (e.g. A big malloc will not reserve physical memory for you right away, but only as soon as it is used). You can test the impact of this by mapping an anonymous region of memory (or a file) using: #include // allocate anonymous region of memory (1 mb) char *p = mmap(NULL,1024*1024,PROT_WRITE|PROT_READ,MAP_PRIVATE|MAP_ANON,0,0); // actually access the memory, or it will not be resident int sum=0; for(int i=0;iAlso, presumably the leak tester looks from the malloc (library) call onward until a corresponding free, while the actual memory reservation is done just one level lower, e.g. Using a mmap (system) call just like the one above.

In Instruments, I am seeing that the memory returned by task_info is much less than reported by the VM Tracker. Is this because task_info is only counting the memory from the process whereas VM Tracker is also including the shared memory? – kejadlen Dec 15 at 18:24 No, most probably you are looking at the difference between resident memory (memory pages that are actually in RAM) vs. virtual memory (memory pages that reside on swap, on disk as files, or nowhere yet; see the mmap/MAP_ANON example).

On Mac OS X, run vmmap -resident $$ in your terminal to see the numbers for your shell ($$ is the PID of your shell). As far as your process knows, the virtual pages are just there, but if you access them, the OS needs to get them first. Using mincore(2) you can test if a page of memory is resident, and if not, you can measure a delay when accessing it.

– mvds Dec 16 at 1:20 Taking an extreme example: you can mmap() an entire block device, like your 1TB harddisk, and your process can then simply access the disk contents from memory, instead of using read() system calls. The VM tracker will then say you have 1TB of virtual memory, with only a fraction of it resident in RAM. (note: you need a 64 bit OS for such experiments) – mvds Dec 16 at 1:24 I get that, but what I'm wondering is why VM Tracker and task_info report different values for resident and virtual.

Both tools give values for resident and virtual, but task_info reports a lower value for resident and higher value for virtual than VM Tracker, so I don't know what either is actually reporting. – kejadlen 2 days ago dunno, maybe your measurement influences your observable. Are you measuring at the exact same instant?

– mvds yesterday.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions