2

I've seen some methods that use task_info() to retrieve the memory usage of an IOS app within the app:

Programmatically retrieve memory usage on iPhone

How to get memory usage of my application and system in swift by programatically

I want to know that if the app releases some memory, will it show up in task_info() immediately? That is, will IOS keep counting the memory until the IOS cleans up memory.

I don't think IOS does garbage collection, and ARC is just a compiler feature.

It seems to me that task_info() should give accurate memory info, but I'd like to double check.

Thanks.

Community
  • 1
  • 1
Fei
  • 769
  • 2
  • 7
  • 13
  • I'm pretty sure that on Linux there isn't actually a way to release memory back to the operating system. Memory that is `free()`ed is marked as free in some tables kept by the process, and can be used to satisfy future `malloc()`s within the same process, but the memory is unavailable to other processes until the process exits and is cleaned up. It's possible that the same is true for BSD/Darwin/iOS, but if someone would actually confirm this that'd be great. – Linuxios Apr 20 '17 at 23:40
  • OK, and never mind: apparently there are mechanisms, they just aren't used very often (by programmers or the system): https://stackoverflow.com/questions/2215259/will-malloc-implementations-return-free-ed-memory-back-to-the-system. This sort of setup almost certainly applies to iOS too. – Linuxios Apr 20 '17 at 23:42

0 Answers0