• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
CoreData huge memory usage - is this right ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CoreData huge memory usage - is this right ?


  • Subject: CoreData huge memory usage - is this right ?
  • From: Martin Linklater <email@hidden>
  • Date: Fri, 14 Dec 2007 06:38:19 -0800

Hi - I'm in the process of writing code which will create and populate a CoreData SQLite store. I have a few million objects to deal with. I have written code which imports a text description of my data and then iterates through inserting and setting attributes of my CoreData objects. Things are going fine with the exception of one problem I am having... I am seeing CoreData take huge amounts of RAM to do it's thing. When my SQLite store is at around 10MB in size, my task is taking upwards of 500+MB of memory.

I have run my application through 'Instruments' and the major culprit for all this memory usage is CoreData - namely the 'GeneralBlock-x' where x is a number. I am trying to track down this memory leak but I'm stuck as to where it is coming from. My code follows the standard template XCode code for a CoreData Application, and I am simply iterating through my object like this:

while( not end of file )
{
    id coreDataElement = [NSEntityDescription insertNewObjectForEntityForName:name in ManagedObjectContext:moc];

    // add my attributes for the element
    [coreDataElement setValue:value forKey:key];
    [coreDataElement setValue:value forKey:key];
    [coreDataElement setValue:value forKey:key];
    etc.

    [coreDataElement release];

    // then every 1000 entries or so I am saving the context

    [moc save:&error];

}

This code is executing fine, and my elements are indeed being inserted into the CoreData store because I have ran this code with an XML store and things are being stored fine. Saving of the moc is returning with no errors too.

So I am stumped as to why CoreData is allocating an awful lot of memory for this task... can anyone shed some light on what I'm doing wrong ?

Apologies if this is a trivial error - I am very new to CoreData.

Thank you.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: CoreData huge memory usage - is this right ?
      • From: Frank Reiff <email@hidden>
    • Re: CoreData huge memory usage - is this right ?
      • From: email@hidden
  • Prev by Date: Xcode cocoa project with c++
  • Next by Date: Re: CoreData huge memory usage - is this right ?
  • Previous by thread: Re: Xcode cocoa project with c++
  • Next by thread: Re: CoreData huge memory usage - is this right ?
  • Index(es):
    • Date
    • Thread