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 3233796
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:19:05+00:00 2026-05-17T17:19:05+00:00

I’ve got an app that throws out the GKSession and makes a new one

  • 0

I’ve got an app that throws out the GKSession and makes a new one under various conditions (connection timeout, session fails, etc.). I’m getting memory leaks, though, and it sometimes crashes after a few loops through the reconnect.

Here’s my code:

- (void) netConnect:(id) sender {
     NSLog(@"allocating GKSession");

     currentSession = [[GKSession alloc] initWithSessionID:nil displayName:nil sessionMode:GKSessionModePeer];
     currentSession.delegate = self;
     currentSession.available = YES;
     currentSession.disconnectTimeout = 0;
     [currentSession setDataReceiveHandler: self withContext:nil]; 
        }

- (void) netDisconnect:(id) sender {
     NSLog(@"DISCONNECTING BY REQUEST");

     [currentSession disconnectFromAllPeers];
     [currentSession setAvailable:NO];
     [currentSession setDelegate:nil];
     [currentSession setDataReceiveHandler:nil withContext:nil];
     [currentSession release];
     currentSession = nil;
    }

There’s a timer that waits for a successful connection; if it doesn’t get one, netDisconnect is called, followed by netConnect again after a 5-second NSTimer delay.

I’m getting leaked GKList, GKTable, and GKAutoPeerIDTable objects, and crashes like this (always occurs after the alloc) :

  Date/Time:       2010-09-05 09:35:59.426 -0700
  OS Version:      iPhone OS 4.0.2 (8A400)
  Report Version:  104

  Exception Type:  EXC_BAD_ACCESS (SIGBUS)
  Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000a
  Crashed Thread:  0

  Thread 0 Crashed:
  0   libobjc.A.dylib                0x0000286c objc_msgSend + 16
  1   CoreFoundation                 0x000756ea __CFCopyFormattingDescription + 174
  2   CoreFoundation                 0x00081c8e __CFStringAppendFormatCore + 8666
  3   CoreFoundation                 0x000146ac _CFStringCreateWithFormatAndArgumentsAux + 64
  4   CoreFoundation                 0x00014660 CFStringCreateWithFormatAndArguments + 16
  5   CoreFoundation                 0x0001463c CFStringCreateWithFormat + 16
  6   SystemConfiguration            0x00003272 SCDynamicStoreCreateWithOptions + 62
  7   SystemConfiguration            0x000033d0 SCDynamicStoreCreate + 12
  8   GameKitServices                0x000020ce gckRegisterForNetworkChanges + 154
  9   GameKitServices                0x000035c0 GCKSessionCreate + 788
  10  GameKitServices                0x00035e7a -[GKSessionInternal initWithSessionID:displayName:session:sessionMode:] + 274
  11  GameKit                        0x0000fda8 -[GKSession initWithSessionID:displayName:sessionMode:] + 76

Here’s another one:

Sun Sep  5 10:28:52 thinner someapp[424] <Warning>: allocating GKSession
Sun Sep  5 10:28:52 thinner someapp[424] <Error>: -[__NSCFData UTF8String]: unrecognized selector sent to instance 0x10a710
Sun Sep  5 10:28:52 thinner someapp[424] <Error>: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFData UTF8String]: unrecognized selector sent to instance 0x10a710'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x31a9ffd3 __exceptionPreprocess + 114
    1   libobjc.A.dylib                     0x3428a8a5 objc_exception_throw + 24
    2   CoreFoundation                      0x31aa3a77 -[NSObject(NSObject) doesNotRecognizeSelector:] + 102
    3   CoreFoundation                      0x31aa2f15 ___forwarding___ + 508
    4   CoreFoundation                      0x31a35680 _CF_forwarding_prep_0 + 48
    5   GameKitServices                     0x327aff13 -[GKSessionInternal initWithSessionID:displayName:session:sessionMode:] + 426
    6   GameKit                             0x31c15daf -[GKSession initWithSessionID:displayName:sessionMode:] + 82
    7   someapp                        0x0000584b -[MainViewController netConnect:] + 126

Questions:
• Is this the right way to release and re-allocate GKSessions?
• Should I not be tearing down and re-allocating GKSessions between connections to begin with?

  • 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-17T17:19:05+00:00Added an answer on May 17, 2026 at 5:19 pm

    This is a known issue. The workaround is to not pass in nil for the sessionID:
    [[GKSession alloc] initWithSessionID:@”com.put.something.here” displayName:nil sessionMode:GKSessionModePeer];

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

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
We're building an app, our first using Rails 3, and we're having to build
I need to clean up various Word 'smart' characters in user input, including but
i got an object with contents of html markup in it, for example: string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.