+uint64_t get_task_resident_size(task_t task)
+{
+ vm_map_t map;
+
+ map = (task == kernel_task) ? kernel_map: task->map;
+ return((uint64_t)pmap_resident_count(map->pmap) * PAGE_SIZE_64);
+}
+
+uint64_t get_task_compressed(task_t task)
+{
+ vm_map_t map;
+
+ map = (task == kernel_task) ? kernel_map: task->map;
+ return((uint64_t)pmap_compressed(map->pmap) * PAGE_SIZE_64);
+}
+
+uint64_t get_task_resident_max(task_t task)
+{
+ vm_map_t map;
+
+ map = (task == kernel_task) ? kernel_map: task->map;
+ return((uint64_t)pmap_resident_max(map->pmap) * PAGE_SIZE_64);
+}
+
+uint64_t get_task_purgeable_size(task_t task)
+{
+ kern_return_t ret;
+ ledger_amount_t credit, debit;
+ uint64_t volatile_size = 0;
+
+ ret = ledger_get_entries(task->ledger, task_ledgers.purgeable_volatile, &credit, &debit);
+ if (ret != KERN_SUCCESS) {
+ return 0;
+ }
+
+ volatile_size += (credit - debit);
+
+ ret = ledger_get_entries(task->ledger, task_ledgers.purgeable_volatile_compressed, &credit, &debit);
+ if (ret != KERN_SUCCESS) {
+ return 0;
+ }
+
+ volatile_size += (credit - debit);
+
+ return volatile_size;
+}
+
+/*
+ *
+ */
+uint64_t get_task_phys_footprint(task_t task)
+{
+ kern_return_t ret;
+ ledger_amount_t credit, debit;
+
+ ret = ledger_get_entries(task->ledger, task_ledgers.phys_footprint, &credit, &debit);
+ if (KERN_SUCCESS == ret) {
+ return (credit - debit);
+ }
+
+ return 0;
+}
+
+/*
+ *
+ */
+uint64_t get_task_phys_footprint_max(task_t task)
+{
+ kern_return_t ret;
+ ledger_amount_t max;
+
+ ret = ledger_get_maximum(task->ledger, task_ledgers.phys_footprint, &max);
+ if (KERN_SUCCESS == ret) {
+ return max;
+ }
+
+ return 0;
+}
+
+/*
+ *
+ */
+uint64_t get_task_phys_footprint_limit(task_t task)
+{
+ kern_return_t ret;
+ ledger_amount_t max;
+
+ ret = ledger_get_limit(task->ledger, task_ledgers.phys_footprint, &max);
+ if (KERN_SUCCESS == ret) {
+ return max;
+ }
+
+ return 0;
+}
+
+uint64_t get_task_internal(task_t task)
+{
+ kern_return_t ret;
+ ledger_amount_t credit, debit;
+
+ ret = ledger_get_entries(task->ledger, task_ledgers.internal, &credit, &debit);
+ if (KERN_SUCCESS == ret) {
+ return (credit - debit);
+ }
+
+ return 0;
+}
+
+uint64_t get_task_internal_compressed(task_t task)
+{
+ kern_return_t ret;
+ ledger_amount_t credit, debit;
+
+ ret = ledger_get_entries(task->ledger, task_ledgers.internal_compressed, &credit, &debit);
+ if (KERN_SUCCESS == ret) {
+ return (credit - debit);
+ }
+
+ return 0;
+}
+
+uint64_t get_task_purgeable_nonvolatile(task_t task)
+{
+ kern_return_t ret;
+ ledger_amount_t credit, debit;
+
+ ret = ledger_get_entries(task->ledger, task_ledgers.purgeable_nonvolatile, &credit, &debit);
+ if (KERN_SUCCESS == ret) {
+ return (credit - debit);
+ }
+
+ return 0;
+}
+
+uint64_t get_task_purgeable_nonvolatile_compressed(task_t task)
+{
+ kern_return_t ret;
+ ledger_amount_t credit, debit;
+
+ ret = ledger_get_entries(task->ledger, task_ledgers.purgeable_nonvolatile_compressed, &credit, &debit);
+ if (KERN_SUCCESS == ret) {
+ return (credit - debit);
+ }
+
+ return 0;
+}
+
+uint64_t get_task_alternate_accounting(task_t task)
+{
+ kern_return_t ret;
+ ledger_amount_t credit, debit;
+
+ ret = ledger_get_entries(task->ledger, task_ledgers.alternate_accounting, &credit, &debit);
+ if (KERN_SUCCESS == ret) {
+ return (credit - debit);
+ }
+
+ return 0;
+}
+
+uint64_t get_task_alternate_accounting_compressed(task_t task)
+{
+ kern_return_t ret;
+ ledger_amount_t credit, debit;
+
+ ret = ledger_get_entries(task->ledger, task_ledgers.alternate_accounting_compressed, &credit, &debit);
+ if (KERN_SUCCESS == ret) {
+ return (credit - debit);
+ }
+
+ return 0;
+}
+
+uint64_t get_task_page_table(task_t task)