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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:16:57+00:00 2026-06-05T13:16:57+00:00

I have recently inherited a large project using an sqlite3 database and currently I

  • 0

I have recently inherited a large project using an sqlite3 database and currently I am muscling through a significant amount of memory leaks scattered throughout. A couple of the leaks have me confused and demoralised after not being able to solve them. This loop within a method leaks an awful amount of bytes but appears to be so simplistic I simply don’t know how to change it to prevent the leak.

...
    while ((ret=sqlite3_step(selStmt))==SQLITE_ROW) 
    { 

        GraphData *item = [GraphData alloc];

        item.key = sqlite3_column_int(selStmt, 0);
        item.value = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selStmt,1)];

        [newData addObject:item]; 

        [item release], item = nil;

    }
...

    @interface GraphData : NSObject{

    NSInteger key;
    NSString *value;
}

@property (nonatomic, readwrite) NSInteger key;
@property (nonatomic, retain) NSString *value;

-(id)initWithPrimaryKey:(NSInteger) xid;
-(id)initWithName:(NSString *)n key:(NSInteger)i;

@end



    #import "GraphData.h"

@implementation GraphData

@synthesize  key,value;

-(id)initWithPrimaryKey:(NSInteger) xid{

    self.key = xid;
    self.value = @"";

    return self;

}
-(id)initWithName:(NSString *)n key:(NSInteger)i{

    self.key = 0;
    self.value = n;

    return self;

}

@end

Almost all the leaks within this datasource class come from this loop.

I’m hoping this is something trivial that my inexperience has overlooked.

Thanks for taking the time to look at my question.

  • 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-05T13:16:58+00:00Added an answer on June 5, 2026 at 1:16 pm

    There’s no dealloc in your GraphData class.

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

    (I assume you’re not using ARC because you have release in your first code snippet. I really recommend converting to ARC – this kind of leak vanishes.)

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

Sidebar

Related Questions

I have recently inherited a large web project. Before taking this on, I had
I have recently inherited an ASP.Net app using Linq2SQL. Currently, it has its DataContext
I recently inherited a large software project written in Java. The last developer used
I have inherited a WiX project from a contractor that recently left. When I
I've recently inherited a fairly large web site. The project is set up as
I have recently inherited a website written in Classic ASP, and am currently trying
I have recently inherited a large website. I have been checking it for security
I recently inherited a project that is using Spring SAML 2.0 but the code
I have recently started using DocCheck for checking the validity of JavaDoc's in code
I have recently started to learn Objective-C and write my tests using OCUnit that

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.