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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:40:07+00:00 2026-05-25T01:40:07+00:00

Instruments is informing me that I am leaking memory from the following code snippet

  • 0

Instruments is informing me that I am leaking memory from the following code snippet

for (int x=0; x<20; x++)
{

LeagueTableRow *aLTR = [[LeagueTableRow alloc] init];   //leaks a certain percentage here

match = [substring rangeOfString: @"text team large-link"];

if (match.location == NSNotFound) 
{
}
if  ((match.location + match.length) > ([substring length]))
{
}

substring = [substring substringFromIndex:(match.location + match.length)];

match2 = [substring rangeOfString: @"title="];
substring = [substring substringFromIndex:(match2.location + match2.length+1)];

match2 = [substring rangeOfString: @">"];

aLTR.teamName = [substring substringToIndex:match2.location-1]; //leaks a percentage here

match2 = [substring rangeOfString: @"number total mp"];
substring = [substring substringFromIndex:(match2.location + match2.length+1)];

match = [substring rangeOfString: @">"];
match2 = [substring rangeOfString: @"<"];



aLTR.played = [substring substringWithRange:NSMakeRange(match.location+1, (match2.location-(match.location+1)))]; //leaks a percentage here

[self.theLeagueTableArray addObject:aLTR];
[aLTR release];

}

The instruments informs me of the leak and where I commented the code saying there is a leak it says that this line is a cause of a certain percentage of the leak.

The LeagueTableRow class is a very simple container class and each of the vars in it are released at the dealloc for the class.

What could be the issue here?

I alloc aLTR at the start of the loop and then release aLTR at the end of the loop.
The NSString methods are all autorelease on the returned strings AFAIK so the code seems tight.

Anybody able to shed some light on this confusing situation ? The build and analyze tool doesnt mention any issues here either.

Many Thanks,
-Code

  • 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-25T01:40:07+00:00Added an answer on May 25, 2026 at 1:40 am
    [self.theLeagueTableArray addObject:aLTR];
    

    if the backing instnce variable for this theLeagueTableArray is never released, neither will any of the league table rows in it. Check your dealloc method for this class and make sure the variable is released there.

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

Sidebar

Related Questions

Instruments' Leaks tells me that this UIImage is leaking: UIImage *image = [[UIImage alloc]
Instruments tells me the following line from the code below is leaking: I can't
Instruments shows me that I have a leak in the following code: CGContextMoveToPoint(c, startPoint.x,
Instruments leaks says that this code leaks: NSString *name = [file substringToIndex:i]; Layer *actualLayer
So Instruments tells me I have three memory leaks originating in this method (specifically,
I´m using instruments to find memory leaks, and it found a lots! But i
I have checked using instruments and not found any memory leaks. when i check
i use instruments to track my app's usage of memory,in memory monitor,i find that
After running the Leaks Instruments on an app that I am developing, I see
I'm getting an instruments Memory Leak with this iPhone 3.0 SDK code. I'm using

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.