When referencing the value of an instance variable of type NSString, it may sometimes appear as <__NSMallocBlock__: 0x106452d60>.

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?

Answered by DTS Engineer in 856502022

These are the classic symptoms of an over-release bug. Something is over-releasing this object which eventually causes it to get deallocated even though you still have a strong reference to it. Later on, some other object gets allocated and happens to use the same memory, and presto! an object you ‘own’ has changed type.

The canonical way to debug such things is with zombies. See Standard Memory Debugging Tools for more info about that.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

These are the classic symptoms of an over-release bug. Something is over-releasing this object which eventually causes it to get deallocated even though you still have a strong reference to it. Later on, some other object gets allocated and happens to use the same memory, and presto! an object you ‘own’ has changed type.

The canonical way to debug such things is with zombies. See Standard Memory Debugging Tools for more info about that.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

When referencing the value of an instance variable of type NSString, it may sometimes appear as &lt;__NSMallocBlock__: 0x106452d60&gt;.
 
 
Q