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

  • Home
  • SEARCH
  • 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 6468195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:52:02+00:00 2026-05-25T05:52:02+00:00

XCode is suggesting that an [NSString initWithFormat] method (as listed in the Instruments window)

  • 0

XCode is suggesting that an [NSString initWithFormat] method (as listed in the Instruments window) is the source of a memory leak. It lists the particular method, so in that method I identified the only line of code with initWithFormat (as unlike some leaks identified in Instruments, this one will not take me to the exact offending line of code for some reason):

 NSString * name=[[NSString alloc] initWithFormat:@"%@",[[lineArray objectAtIndex:0] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] ];

 CustomObject * newData=[[CustomObject alloc] init];
 newData.info=name; // info is a retained NSString ivar of CustomObject

 [name release];
 [self.ivar setObject:newData forKey:@"key"];
 [newData release];

The initWithFormat and the release are within the same scope: both occur inside an if statement.

Are there some NSString methods that somehow call initWithFormat without it being obvious in the code? Such as these stringByTrimmingcharactersInSet type methods?

UPDATE: I’ve added all the code between the initWithFormat and the release — Also, even if I change initWithFormat to stringWithFormat, Xcode gives me the same memory leak, instead identifying stringWithFormat, so this is clearly the object causing the problem.

  • 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-25T05:52:02+00:00Added an answer on May 25, 2026 at 5:52 am

    Instruments doesn’t show where the object was leaked; it shows where the object that was leaked was created. So what’s probably going on is you’re not releasing the info ivar of your CustomObject class in its dealloc method. Either that, or you’re over-retaining that object somewhere else.

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

Sidebar

Related Questions

In Xcode method listings (activated via Ctrl-2), the method names are always listed in
When Xcode autocompletes an method for me, it gives me blue blocks for parameters.
I've an application with the following category for NSString: @interface NSDate(ISO8601Parsing) //This method is
I have a lot of warnings in my Xcode project about old files that
I understand that those who installed Xcode 4 via the developer site are able
On another forum based site I was informed that the OpenGL-es in xcode could
I created an application in XCode 4 that uses Core Plot. I installed Core
I'm trying to use XCode's Leaks utility to fix some memory leaks in my
I am building ipad application in XCode 4. For that, i added some outside
It turns out that using cvCaptureFromCAM creates a memory in initialization. Usage of cvCaptureFromCAM

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.