Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 605579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:09:40+00:00 2026-05-13T17:09:40+00:00

When I check a singleton property that is nil, it kills my app. But

  • 0

When I check a singleton property that is nil, it kills my app. But when I check for nil on a class instance property, everything works fine.

This works fine:

self.MyProperty == nil

but this will kill the app with “EXC_BAD_ACCESS”

[MySingleton sharedManager].SomeProperty != nil

What is the difference with the singleton that I can’t check for nil?

Here’s the singleton implementation:

.h file:

@interface MySingleton : NSObject {
    NSString * SomeProperty;
}
@property (nonatomic, copy) NSString * SomeProperty;
+(MySingleton *)sharedManager;
@end

.m file:

#import "MySingleton"

static MySingleton *sharedManager = nil;

@implementation MySingleton
@synthesize SomeProperty;

- (void)dealloc {
     [SomeProperty dealloc];
     [super dealloc];
}

+(MySingleton *)sharedManager
{       
    if (!sharedManager){
         sharedManager = [[MySingleton alloc] init];
    }
    return sharedManager;   
}

This is what I find in the console when when trying to assign something to SomeProperty:

MyApp(51363,0xa0389500) malloc: *** mmap(size=2147487744) failed (error code=12)
*** error: can't allocate region  
*** set a breakpoint in malloc_error_break to debug
Current language:  auto; currently objective-c  
(gdb) break malloc_error_break  
Note: breakpoints 6 and 8 also set at pc 0x929c2072.
Breakpoint 11 at 0x929c2072  
(gdb) continue  
(gdb) po [MySingleton sharedManager].SomeProperty
Cannot access memory at address 0x0  
(gdb) po [MySingleton sharedManager]
<Session: 0x1938fa0>

I get the above only when trying to assign. When trying to read the variable is where the crash occurs.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T17:09:40+00:00Added an answer on May 13, 2026 at 5:09 pm

    Given this:

    - (void)dealloc {
    [someKey dealloc];
    [super dealloc];
    }
    

    And some of the other code, I’d go out on a limb and say it is likely that there are other problems with the code, the combination of which are leading to the problem you have hinted at. In particular, you should never call -dealloc directly (other than [super dealloc]). If you have that in other parts of your code and it is being executed, it could easily cause the symptom you describe.

    If you want a more specific answer, post the backtrace of the crash.

    MyApp(51363,0xa0389500) malloc: * mmap(size=2147487744) failed (error code=12) error: can't allocate region
    ** set a breakpoint in malloc_error_break to debug Current language: auto; currently objective-c
    

    Set the breakpoint as indicated and then re-run the application. Once that error message happens, all bets are off as your app is already hosed. You need the backtrace of when that call is made.

    What is happening, though, is that something is asking mmap() to map in 2GB of address space. Could be corruption. Could be bad code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.