[baseten-users] BXDatabaseContext, batch processing and memory usage question

Tuukka Norri tuukka.norri at karppinen.fi
Thu Sep 10 00:43:53 EEST 2009


Hi!
I'm sorry about not replying to your or anyone else's e-mails earlier.  
We all have been quite stuffed with work lately but hope to be able to  
continue improving BaseTen as soon as possible.

Jianhua Meng kirjoitti 18.8.2009 kello 3.33:
> We have a need to support batch processing via a BXDatabaseContext  
> object. With a given job, there might be a need to fetch a lot of  
> objects from the underlying database. At some point, "too many  
> objects" may reside in a database context. To avoid potential memory  
> hogging, I'm thinking about periodically perform some house keeping  
> against a database context to get rid of objects that are no longer  
> needed. What's the best way to go about that?  Is there an easy way  
> to purge a database context of all existing objects or selected  
> objects?


The database context doesn't have strong references to database  
objects with either manual memory management or garbage collection.
When using manual MM, the context may be set to retain registered  
(fetched) objects with -setRetainsRegisteredObjects:. Otherwise, when  
collections of fetched objects get deallocated, all fetched objects  
should get freed as well, unless they have been retained by something  
else.

As far as I know, array controllers do have a strong reference to  
their content. One could alleviate the problem by periodically setting  
the controller's content to nil and fetching another set of relevant  
objects, for example.

Although we don't yet support NSFetchRequest's new functionality,  
there are some other ways to reduce memory usage. Columns that  
shouldn't be fetched initially may be specified as excluded when  
executing a fetch. In case none of the property values are needed,  
objects may also be fetched as faults.
-- 
Best regards,
Tuukka Norri
MK&C




More information about the baseten-users mailing list