Mark,
29.03.2011 18:27, Mark Murphy пишет:
On Tue, Mar 29, 2011 at 10:19 AM, Kostya Vasilyev<kmans...@gmail.com> wrote:
> There is no leaked database connection with Content Providers.
Yes, there is, at least by my definition (close() not being called).
By this definition, every program running in a non-GC environment has a
memory leak, which would be a very interesting point of view.
To me, a leak is where the use of some resource grows over time and has
no chance of decreasing. The resource in question may be memory, open
files, DMA buffers, etc.
In this particular case, there is only one file which is kept open, and
that number does not grow over time. Opening a new database connection
for every db operation would be a leak, but that is not happening here.
Besides, not closing a database is not specific to content providers.
An application that shares a database object among different components
might keep it open as well.
> What happens is, the database is kept open as long as the application
> process is alive, and is open just once, too.
>
> When/if the process is killed, the OS kernel closes the file.
That presumes that there is no SQLite logic in a database close() that
is important. One hopes that is the case, given the way content
providers are implemented.
It seems safe to not close a SQLite database, based on empirical
evidence supported by some ten million Android devices worldwide, all
having some databases and content providers, including those built into
the platform.
Besides empirical evidence, see this comment made by the author of
SQLite, D. Richard Hipp:
http://www.mail-archive.com/sqlite-users@sqlite.org/msg01280.html
Program crashes, OS crashes, and power failures should not
corrupt an SQLite database.
--
Kostya Vasilyev -- http://kmansoft.wordpress.com
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en