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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:15:52+00:00 2026-05-15T17:15:52+00:00

I’m using CoreData (with SQLite as the store) in an iOS 4 iPhone application

  • 0

I’m using CoreData (with SQLite as the store) in an iOS 4 iPhone application to store data that i initially retrieve from an xml file. My data model contains more than 15 entities and I am concerned about memory consumption since I saw CoreData creating all the NSManagedObject in memory to represent the object graph of my data model.
I parse the xml file with a SAX libxml2 based parser and try to store each ‘agglomerate set’ of entities together chunk by chunk, but i’d like to release each managedobject after this agglomerate has been inserted and the managed context saved, in order to save memory for the next agglomerate.
I saw that i have to use refreshObject: mergeChanges: to counterbalance the multiple retain each object has received while associated to others by relationships (as designed in the data model). I do that after saving the context, but next when I try to look up again in the store trying to fetch what I inserted before it returns nothing.
Am I missing something?

  • 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-15T17:15:53+00:00Added an answer on May 15, 2026 at 5:15 pm

    If all you do is importing (e.g. you don’t need to keep the inserted objects to display to the user and so on), you can simply use [moc reset] after the save. So the algorithm would look something like this:

    NSManagedObjectContext* moc = ...;
    while ([xmlData hasMoreObjects]) {
        // Create e.g. 500 objects and insert them into the managed object context
        NSError* error = nil;
        if (![moc save:&error]) {
            // handle the error
        }
        [moc reset]; // Here the inserted objects get released in the core data stack
    }
    

    Resetting the managed object context does the same as if you would refresh every object (as you did before). Also you should consider using the [[NSManagedObject alloc] initWithEntity:insertIntoManagedObjectContext:] instead of the convenience methods on NSEntityDescription, because you can release them just after you don’t need them anymore, and they won’t stay in memory until the autorelease pool gets cleared.

    Take a look at the Core Data Programming Guide, as it contains a whole section centered around efficiently importing data and one about memory management with Core Data.

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

Sidebar

Related Questions

We are using XSLT to translate a RIXML file to XML. Our RIXML contains
That's pretty much it. I'm using Nokogiri to scrape a web page what has
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm parsing an XML file, the creators of it stuck in a bunch social
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

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.