You want TASK_VM_INFO, and you'll want the "phys_footprint" member. On all Apple OSes you are only charged for "dirty(written to)" and "wired" memory. There are interesting edge cases with mapped files, but I won't get into those.
That is now what top and Xcode use.