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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:31:26+00:00 2026-05-23T12:31:26+00:00

Following methods gets called from didFinishLaunchingWithOptions,when I run on Instruments openDatabase method causing leaks..

  • 0

Following methods gets called from didFinishLaunchingWithOptions,when I run on Instruments openDatabase method causing leaks..
please suggest me how to clear

- (NSString*)getdestinationPath {
    NSArray *pathsArray=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
    NSString *doumentDirectoryPath=[pathsArray objectAtIndex:0];
    NSString *destinationPath=[doumentDirectoryPath stringByAppendingPathComponent:dataBaseName];
    NSLog(@"database path %@",destinationPath);
    return destinationPath;
}




- (void)chkAndCreateDatbase {
    NSFileManager *fileManger=[NSFileManager defaultManager];
    NSError *error;
    NSString *destinationPath=[self getdestinationPath];
    if ([fileManger fileExistsAtPath:destinationPath]){
        //NSLog(@"database localtion %@",destinationPath);
        return;
    }
    NSString *sourcePath=[[[NSBundle mainBundle] resourcePath]stringByAppendingPathComponent:dataBaseName];
    [fileManger copyItemAtPath:sourcePath toPath:destinationPath error:&error];
}





- (void)openDatabase {
    path=[self getdestinationPath];
    if (sqlite3_open([path UTF8String], &database)==SQLITE_OK) // here leak is showing
    {
        NSLog(@"dataBaseOpen");
    }
    else {
        sqlite3_close(database);
        NSLog(@"dataBaseNotOpen");  
    }   
}
  • 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-23T12:31:27+00:00Added an answer on May 23, 2026 at 12:31 pm

    You are leaking because you’re not calling sqlite3_close(database)
    when you get SQLITE_OK.

    if (sqlite3_open([path UTF8String], &database)==SQLITE_OK) 
    {
        NSLog(@"dataBaseOpen");
        // leak happens here, do stuff then call sqlite3_close(database), or move it out of the if/else block.
    
    }
    else {
        sqlite3_close(database);
        NSLog(@"dataBaseNotOpen");  
    }   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the 2 following methods of reading a string from a file: NSString *path
Please see following methods. public static ProductsCollection GetDummyData(int? customerId, int? supplierId) { try {
My web service method returns a Page object which includes the following methods: public
I have an unmanaged DLL that gets called from .NET with pre-allocated buffers to
In views.py I have the following view which gets called when a new user
I have a subprocess function (called parseContents) that gets called using the following code:
Can you please tell me How can I get Control back from NSOperationQueue Following
Say I have the following methods: def methodA(arg, **kwargs): pass def methodB(arg, *args, **kwargs):
I have seen the following methods of putting JavaScript code in an <a> tag:
I am using the following methods: public void M1(Int32 a) { // acquire MyMutex

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.