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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:37:31+00:00 2026-05-20T11:37:31+00:00

I am working on an app that imports a (very) large csv file into

  • 0

I am working on an app that imports a (very) large csv file into Core Data for catching purposes. The process goes something like this:

  1. Parse the file line-by-line into an NSMutableArray full of NSStrings
  2. After X number of lines, import the array into Core Data (this involves manipulating and in some cases creating new NSStrings)
  3. [NSMutableArray removeAllObjects];
  4. Rinse and repeat

At first glance it looks like the memory should be freed up at the conclusion of each cycle. With large files, however, I am finding that the app crashes after signaling a couple low memory warnings. Running the leaks tool tells me that most of the memory is being used up by CFString objects, which I understand are related to NSString objects (although I don’t know how)

I understand that NSString are reused whenever possible, and that they don’t act quite the same as other objects where memory is concerned, although I don’t understand any of the details. How can I reclaim the memory that my NSString objects are using?

  • 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-20T11:37:32+00:00Added an answer on May 20, 2026 at 11:37 am

    Running the leaks tool tells me that most of the memory is being used up by CFString objects, which I understand are related to NSString objects (although I don’t know how)

    NSString is actually a class cluster. Although you think you are working with NSStrings, you are almost certainly really working with one of its subclasses. The Cocoa framework chooses which subclass to use depending on circumstances.

    CFString is actually not really an NSString at all, it is the pure C string object used by Core Foundation. However, you’ll find it is “toll free bridged” to NSString. This means that, to Cocoa, it looks like an NSString. The reason you are seeing lots of CFString usage is because whatever Cocoa API you are using to obtain these strings ultimately performs its work in Core Foundation.

    Anyway, all that is irrelevant to your problem except for the fact, that lots of CFStrings more or less means the same as lots of NSStrings. What you need to reduce your memory footprint is nested autorelease pools as Girish has already said. As a first step, modify your algorithm like this:

    1. Create a new autorelease pool.
    2. Parse the file line-by-line into an NSMutableArray full of NSStrings
    3. After X number of lines, import the array into Core Data (this involves manipulating and in some cases creating new NSStrings)
    4. [NSMutableArray removeAllObjects];
    5. drain the autorelease pool
    6. Rinse and repeat (start at 0)

    If this doesn’t help, or only helps a bit, consider bracketing just the parsing with an autorelease pool.

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

Sidebar

Related Questions

I'm working on an app that sends raw data to zebra printer and print
I'm working on a java 2ME app that submit data to mysql database (am
I am working on an app that imports photos from facebook. It creates a
I'm working on an app that grabs and installs a bunch of updates off
I'm working on an app that requires no user input, but I don't want
I'm working on an app that needs to intercept when a program tries to
I'm working on an App that talks to a serial port, and on my
I'm working on an app that needs to accept a RegEx from the user,
I'm working on an app that will be using https, but we wanted to
I'm working on an app that allows tagging directly on photos via clicking (like

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.