iPhone 内存问题
我有一个 iPhone 应用程序,可以在其中保存大量图像。 我使用 SQLite 将图像保存到应用程序中。 我保存了 20 多张图像后出现了很多内存问题。
有谁知道用户可以在他们的应用程序数据库中保存多少张图像? 如果它取决于 iPhone 内存,我们怎样才能获得最大限制?
另一件事:
我已经删除了数据库并使用文件系统将图像存储到应用程序中。 但同样的问题又出现了。
任何人都可以建议我这一点吗? 我非常感谢你的大力帮助。
提前致谢。
I have an iPhone application that will save number of images in it.
I used SQLite in-order to save the images into the application.
There were lot of memory issues after i saved more than 20 images.
Do any one know how many images users can save in their app database?.
if it depends on iphone memory, how can we get that max limit?.
One more thing:
I have removed the database and used the file system to store the images into application.
but same problem replicated.
Can any one suggest me on this.
I owe a lot for your great help.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信将图像存储在文件系统中是一个更好的主意,您能否向我们提供更多信息,例如图像大小,以及一些保存代码?
I believe storing the image in the file system is a much better idea, could you provide us with more information, like image size, and also some of your saving code?
当您说“内存问题”时,您是指导致内存不足异常的泄漏,还是确定您的数据库已完全填满设备的磁盘。要了解 SQLite 可以存储多少内容,请阅读此问题的讨论。
另一方面,如果您遇到内存不足异常(didReceiveMemoryWarning),则需要调整代码。特别是,当处理许多图像时,只需避免使用“
imageNamed
”工厂方法即可完成这项工作。这是因为它创建了一个自动释放对象,该对象在内存中保留的时间更长。相反,使用“initWithContentsOfFile
”创建 UIImages 来创建图像并在使用后立即释放它。如果您仍然面临内存问题,则可能存在一些泄漏,需要发布一些代码以便人们能够更正确地回答。When you say 'memory issue', do you mean leaks causing out of memory exceptions or are you sure your database has filled the device's disk completely. To know how much SQLite can store read the discussion on this question.
On the other hand, if you are having out of memory exceptions (didReceiveMemoryWarning) you need to tune your code. Specially, when working with many images, just avoiding the use of '
imageNamed
' factory method does the job. This is because it creates an autorelease object which remains longer in the memory. Instead create UIImages using the 'initWithContentsOfFile
' to create the image and release it immediately after it is used. If you still face the memory issue, you probably have some leaks and need to post some code for people to answer more correctly.