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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:27:39+00:00 2026-05-20T07:27:39+00:00

I have some memory leaks in my app and I think they trace back

  • 0

I have some memory leaks in my app and I think they trace back to my – (id)copyWithZone:(NSZone *)zone method of my ‘Project’ class. The purpose of this copy is to create a deep copy as the values need to be changed without affecting the original values. This class has a custom init method:

- (id)initWithProjectID:(NSInteger)aProjectID name:(NSString *)aProjectName private:(BOOL)isPrivateProject userProjectOrderTieID:(NSInteger)aUserProjectOrderTieID orderID:(NSInteger)anOrderID {
self = [super init];
if (self) {
    projectID = aProjectID;
    projectName = [[NSString alloc] initWithString:aProjectName];
    isPrivate = isPrivateProject;
    userProjectOrderTieID = aUserProjectOrderTieID;
    orderID = anOrderID;
}
return self;
}

and a copy method of:

- (id)copyWithZone:(NSZone *)zone {

Project *copy = [[[self class] allocWithZone:zone]
                 initWithProjectID:projectID
                 name:projectName
                 private:isPrivate
                 userProjectOrderTieID:userProjectOrderTieID 
                 orderID:orderID];

return copy;

}

and for completeness the dealloc method:

- (void)dealloc {
[projectName release];
[super dealloc];
}

All ivars are NSIntegers apart from projectName is a NSString. Can anyone see any issues with this 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-20T07:27:40+00:00Added an answer on May 20, 2026 at 7:27 am

    Nothing stands out as being wrong in what you posted. I suspect the leak is somewhere else. Are you sure the copied Project object being returned is being released properly? Remember that -copyWithZone: returns an object that is already retained.

    The leaks tool would probably identify the line in -copyWithZone: as the offending line where the memory leak originated, because … well it is, but it doesn’t mean that it is the place you need to fix.

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

Sidebar

Related Questions

I have a method which returns some xml in a memory stream private MemoryStream
I'm just investigating some memory leaks in my app, I'm using Xcode 4.0.2. I've
I think that I have a memory leak in my app witch I can't
I want to use the MallocDebug app to find some memory leaks in my
I've noticed some memory leaks in an app i'm building, after playing around with
I have successfully debugged my own memory leak problems. However, I have noticed some
We have a couple of sites which have some memory problems and fairly often
I have some Java code that is throwing out of memory exceptions after running
I have some C code that stores ASCII strings in memory as a four
I have some legacy code that was used to monitor my applications cpu,memory etc

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.