在iphone中使用sqlite数据库时的内存管理 [英] Memory management when using sqlite database in iphone

查看:153
本文介绍了在iphone中使用sqlite数据库时的内存管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序使用SQLite数据库来存储用户的输入。输入中的记录数将大约为100条记录,我在应用程序中进行了大量的SQL操作。

My application makes use of a SQLite database to store the user's inputs. The number of records in the input would go to around 100 records and I have a lot of SQL operations going on in the application.

当我使用Object Allocations运行应用程序时,它显示了sqlite库libsqlite3.0.dylib占用了大量内存。 libsqlite框架会导致内存泄漏吗?与数据库通信的最佳方式是什么?有很多sql调用会增加我的应用程序的内存使用量。

When I run the application with Object Allocations, it shows the sqlite library libsqlite3.0.dylib using up a lot of memory. Does the libsqlite framework lead to memory leakage? What is the best way to communicate with database? Having a lot of sql calls is increasing the memory usage of my app.

有人可以让我知道在应用程序中有效使用sqlite的最佳方法。 (我使用SQLiteBooks示例作为参考)

Can someone please let me know what the best way to use sqlite in an app effectively. (I am using the SQLiteBooks example as the reference)

谢谢。

推荐答案

Sqlite为请求使用缓存。关闭&从时间重新打开数据库以释放缓存。

Sqlite uses a cache for requests. Close & reopen the database from time to release cache memory.

除非您的内存要求很高,否则您不应该关心。

You shouldnt care unless your memory requirements are high.

您可以在 UIApplicationDelegate 方法 applicationDidReceiveMemoryWarning UIViewController 委托方法中捕获关键条件 didReceiveMemoryWarning

You can catch critical conditions in the UIApplicationDelegate method applicationDidReceiveMemoryWarning or UIViewController delegate method didReceiveMemoryWarning

如果调用其中一种方法,请关闭&重新打开数据库。

If one of these methods is called, close & reopen the database.

这篇关于在iphone中使用sqlite数据库时的内存管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆