Executing 120k queries in android

I am doing some sort of benchmark for sqlite android. If I were to pre-load total of 120k before executing, will most device have enough memory? While the queries are executing, there are also other threads that are going on so memory might be the problem. How can I make use of the onLowMemory() method? There doesn't seem to be much examples on using that method. Thanks for any advice.


Making use of the method is as easy as overriding it in your Activity.

However, read the documentation carefully:

This is called when the overall system is running low on memory, and would like actively running process to try to tighten their belt. While the exact point at which this will be called is not defined, generally it will happen around the time all background process have been killed, that is before reaching the point of killing processes hosting service and foreground UI that we would like to avoid killing.

Applications that want to be nice can implement this method to release any caches or other unnecessary resources they may be holding on to. The system will perform a gc for you after returning from this method.

I'm not sure (and the docs don't define) if "background process" includes AsyncTask instances and services, or just backgrounded applications, but I would guess so.

So, when this method is called (if it is ever called) the System has already killed everything it could (with lower priorities than your Activity) and now asks you to release any unnecessary resources in memory.

So, If you want to react on low memory, this might be too late already.

As for the general question if most Android devices would run out of memory, I don't know. The problem is, that devices vary a lot.

I also find it hard to imagine any real live situation, in which you would need to pre-load (or stack) 120k queries before executing. You could easily stack 200 and commit those, than stack another 200 and so on.

I'm not sure why you need to benchmark this, but please don't execute 120k queries for default entries in your applications database.

You can deliver your application with a filled database and copy it over from the assets/-folder. See android-sqlite-asset-helper

Need Your Help

Parsing with TryParse or Parse when data is theoretically always correct?

.net parsing try-catch

I've looked at a few other questions (especially Parsing Performance (If, TryParse, Try-Catch)), and am thinking about the answers. Is it an abuse of exception handling if the exception shouldn't be

get current time / date from php in format similar to 2012-04-24T00:00:00Z

php date

How can I get php to provide me a string I can compare with the datestring format 2012-04-24T00:00:00Z?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.