When the app launches, it assigns the correct string stored in NSUserDefaults to the instance variable (serverAddress) of type NSString.
Afterwards, when the app transitions to a suspended state and receives a VoIP Push notification approximately 4 hours later, causing the app to enter the background state, referencing the value of serverAddress may result in it showing as <NSMallocBlock: 0x106452d60> even though it hasn't been deallocated. This does not occur every time.
The specific class definitions are as follows.
@implementation NewPAPEOPLEClient
{
NSString* serverAddress;
NSString* apiKey;
dispatch_semaphore_t lock;
NSMutableArray* errCallID;
}
#define PREF_STR(key) [[NSUserDefaults standardUserDefaults] stringForKey:(key)
The global instance variable (serverAddress) is set with the following value when the application starts:
serverAddress = PREF_STR(@"APP_CONTACT_SERVICE_SERVER_ADDRESS")
Based on the above, please answer the following questions.
(1) If the instance variable's value becomes <NSMallocBlock: 0x106452d60>, does that mean the memory area has been released?
(2) Can the memory area of an instance variable be automatically released without being explicitly released?
Can an instance variable of type NSString that is not autoreleased be automatically released?
(3) Please tell me how to prevent the memory area from being automatically released. Will using retain prevent automatic release?
Selecting any option will automatically load the page