tags:

views:

119

answers:

2

Hi,

I am using sqlite database and I have around 15-20 queries I need to communicate database and extract data. What I am doing is preparing this querry while the allocation of an DBPersistence Object which takes care of communication with the database. This DBpersistence is a singleton class.

My runtime memory consumption is almost 3MB becoz of which I am getting memory warnings. I am properly resetting every prepared statement after use.

Is there any way to reduce the memory consumption other than using FMDB or CoreData.

A: 

Each sqlite prepared statement, per se, shouldn't be taking up more than a few hundreds of bytes (well, that's a typical prepared statement, of course you could start from a few thousands characters of SQL with hundreds of variables and that would bust things, but I'm assuming you're sane;-). So 15-20 such statements should take up a few KB; I doubt they can explain your megabytes' waste (I don't know how to check what's taking up what memory on iPhone, I'm relying on more ordinary deployment environments for SQLite to gauge these back of the envelope numbers, I imagine the iPhone's memory consumption for SQLite prepared statements is comparable). I suggest you should look elsewhere for the source of your excessive memory consumption.

Alex Martelli
A: 

Are you calling sqlite3_finalize after you are done query execution? It release the memory it created from the prepared statement. This often is the case.

Unikorn