简体   繁体   中英

Cocoa not releasing memory in background

I have an object that allocates memory during its init and releases it during dealloc. When my app is in the background, and these objects are created/released, according to Activity Monitor, the memory is allocated but not released. Only when I click my app to bring it into the foreground is the memory freed.

This is a problem as my app is designed to run in the background.

Any ideas on how to fix this?

Two things comes to mind here...

  1. The app has marked the object to free() the memory allocation. This will happen in the loop whenever the system see fits (since its running in the background).

  2. Some object is still holding a reference to the allocation and doesn't release this reference until you bring the app to the foreground again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM