Object-c SQLite database memory overflow problem, object-csqlite

Source: Internet
Author: User

Object-c SQLite database memory overflow problem, object-csqlite

An application is being developed recently. There are many places in the application that use the SQLite database. Some downloaded content is cached in the SQLite database. A serious problem is found after the application is developed, the program unexpectedly crashed. After analyzing the code using XCode's memory analysis tool, we found that the Controller has been completely released, but the increased memory only released 1/3 when the Controller is opened, after the Controller is turned on and off, it is found that each time the Controller is the same, and the memory overflows after repeated attempts.

 

This is a strange problem. I am very sure that the Delegate of all objects called in the Controller is set to nil, and all created objects are set to nil, however, the memory still cannot be released inexplicably. After repeated debugging, it is found that the SQLite database consumes a lot of memory when it is opened. As long as the database is opened but not closed, the memory will remain at a stable value, that is to say, you do not need to close the database once the program is started, so that the memory can be kept at a very low value for a long time, another advantage is that the SQL Execution is very fast (this is understandable, so you don't need to open or close the database every time you execute the SQL statement ).

 

I have worked on server-side development for a long time. Since I started to access the database, all teaching materials have warned me that I must close the database after I use it, in this way, the connection and memory can be effectively released, but groose IOS is in disguise to encourage the database not to be closed. This is simply revolutionizing my world view. What can I say? I hope you will not encounter the same problems in the future.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.