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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:41:43+00:00 2026-06-08T06:41:43+00:00

the following code crashes.Basically i am accessing a very large string(xml -contains image data)

  • 0

the following code crashes.Basically i am accessing a very large string(xml -contains image data) saved as a file…modifying it and saving it in a new name… when profiling i didnot see any leak with this code… but after repeating this process for 20-25 times… the app crashes on iphone 3gs with memory warning level three and it kills the whole apps running too… i cant find any place where this app is leaking to cause a memory warning ….any suggestions

NSAutoreleasePool *pool=[[NSAutoreleasePool alloc] init];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
 NSString *documents = [paths objectAtIndex:0];
 NSString *filename = [NSString stringWithFormat:@"%@.yyy",fileToDuplicate];
 NSString *initPath = [documents stringByAppendingPathComponent:filename];
 NSString *final = [NSString stringWithFormat:@"%@.yyy",[[alertView textFieldAtIndex:0] text]];
 NSString *finalPath = [documents stringByAppendingPathComponent:final];
 NSString *newName=[[[alertView textFieldAtIndex:0] text] copy];
 NSError *error;
 NSString *xml = [[NSString alloc] initWithContentsOfFile:initPath encoding:NSASCIIStringEncoding error:&error] ;
 NSString *xml_1=[xml stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"<file_name><name>%@.yyy</name></file_name>",fileToDuplicate] withString:[NSString stringWithFormat:@"<file_name><name>%@.yyy</name></file_name>",newName]];
NSString *xml_2=[xml_1 stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"<property_name>%@</property_name>",fileToDuplicate] withString:[NSString stringWithFormat:@"<property_name>%@</property_name>",newName]];
[xml_2 writeToFile:finalPath atomically:YES encoding:NSASCIIStringEncoding error:&error];
 xml=nil;
 [xml release];
 xml_1=nil;
 xml_2=nil;
 [self.mTableView reloadData];
 fileToDuplicate=@"";
 [newName release];
 [pool drain];
 return ;
  • 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-06-08T06:41:44+00:00Added an answer on June 8, 2026 at 6:41 am

    If you don’t see where this is leaking then please switch to ARC. It’s as clear as day in the middle:

    Alloc xml

    Set the variable xml to nil (LEAK!!!!!)

    Release the content of xml (which is nil) <— this does nothing

    The last two are reversed. You need to release it before you set it to nil. I suggest reading a little more about pointers if you do not understand this concept. The release message acts on the content of the pointer, not the pointer itself. The latter wouldn’t make sense.

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

Sidebar

Related Questions

The following code crashes and burns and I don't understand why: DateTime dt =
I wanted to know why the following code crashes. int main( ) { int
When I run the following Code it crashes at the last line. I don't
I have discovered that the following PHP code crashes when it runs on a
The following code compile without errors. Basically, the C#2005 Console application calls VC++2005 class
The following code crashes on the second Pop() call. I'm a novice with C
I am using following code. When the query crashes, it is not displaying the
I am using following code to add tabs on a tabHost but crashes on
I have the following code: NSString *indexText = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; if (indexText==nil)
I have the following code that crashes at the line where I am initializing

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.