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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:21:37+00:00 2026-05-23T02:21:37+00:00

I get the following memory leak errors which correspond with the parser method below.

  • 0

I get the following memory leak errors which correspond with the parser method below. That is every time I use my custom class’s setter (4 times), I get a memory error leak:

Leaked Object   #   Address Size    Responsible Library Responsible Frame
NSCFString  630 < multiple >    20160   Foundation  -[NSCFString copyWithZone:]
NSCFString  625 < multiple >    10000   Foundation  -[NSCFString copyWithZone:]
NSCFString  623 < multiple >    19936   Foundation  -[NSCFString copyWithZone:]
NSCFString  613 < multiple >    23664   Foundation  -[NSCFString copyWithZone:]

my custom class interface:

#import <Foundation/Foundation.h>

@interface FaxRecipient : NSObject {
    NSString * contactID;
    NSString * name;
    NSString * fax;
    NSString * company;
    NSString * phone;
}
@property(nonatomic,copy)NSString *contactID;
@property(nonatomic,copy)NSString *name;
@property(nonatomic,copy)NSString *fax;
@property(nonatomic,copy)NSString *company;
@property(nonatomic,copy)NSString *phone;

@end

implementation:

#import "FaxRecipient.h"

@implementation FaxRecipient
@synthesize contactID, name, fax, company, phone;
@end

I am using it in the following context:

 -(void)parser:(NSXMLParser *)parser
    didStartElement:(NSString *) elementName
     namespaceURI:(NSString *)namespaceURI
    qualifiedName:(NSString *)qName
       attributes:(NSDictionary *)attributeDict
{

    if ([elementName isEqual:@"ContactId"]) {
        faxRecipient =[[FaxRecipient alloc]init];
        remoteRecipientString = [[NSMutableString alloc]init]; 
    }

    else if ([elementName isEqual:@"Name"]) {
        remoteRecipientString = [[NSMutableString alloc]init]; 


    }else if ([elementName isEqual:@"Fax"]) {
        remoteRecipientString = [[NSMutableString alloc]init];
    }

    else if ([elementName isEqual:@"Rec"]) {
        remoteRecipientString = [[NSMutableString alloc]init];
    }

}

-(void) parser:(NSXMLParser *)parser
foundCharacters:(NSString *)string{

    [remoteRecipientString appendString:string];

}


-(void)parser:(NSXMLParser *)parser
didEndElement:(NSString *) elementName
 namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName{


    if ([elementName isEqual:@"ContactId"]) {
        faxRecipient.contactID = remoteRecipientString;
        [remoteRecipientString release];
        remoteRecipientString = nil;
    }


    if ([elementName isEqual:@"Name"]) {
        faxRecipient.name = remoteRecipientString;
        [remoteRecipientString release];
        remoteRecipientString = nil;
    }   


    if ([elementName isEqual:@"Fax"]) {
        faxRecipient.fax = remoteRecipientString;
        [remoteRecipientString release];
        remoteRecipientString = nil;

    }

    if ([elementName isEqual:@"Rec"]) {
        faxRecipient.phone = remoteRecipientString;
        [remoteRecipientItems addObject:faxRecipient];//delivery complete as this is end of xml
        [faxRecipient release];
        faxRecipient = nil;
        [remoteRecipientString release];
        remoteRecipientString = nil;

    }


}
  • 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-23T02:21:38+00:00Added an answer on May 23, 2026 at 2:21 am

    You have to implement the dealloc method where you will release the copied strings.

    - (void) dealloc
    {
        [super dealloc];
        [contactID release];
        [name release];
        [fax release];
        [company release];
        [phone release];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to get the following to analyze a memory leak issue. How to
I have a memory leak when I call the following method - (NSArray *)
Hy all, I believe that the following piece of code is generating memory leak?
The following question answers how to get large memory pages on Windows : how
Why is the following code causing a memory leak in an iPhone App? All
Can the following code cause a memory leak? Would using a StringBuffer actually improve
I'm having a memory leak in the following code. I got 87.5% of the
I'm trying to use the CRT memory leak detection but I keep getting the
When I try to compile the example code given below, I get the following
Is there a memory leak in the following code example as I have allocated

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.