Should The SQLite Cursor Recordset Be Closed Each Time If Same Query Is Rerun

Mahares

Expert
Licensed User
Longtime User
I extract history from 2 tables for any given facility and then create a cursor (recordset) and display the data in the form of a graph. After plotting history for one facility, I go back and create the same query for another facility and plot it. Although I close the cursor, is it essential to close the cursor when finished with one facility and before choosing another to graph. Can I estimate what each query run (recordset) consumes memory wise.
Thank you
 

Mahares

Expert
Licensed User
Longtime User
I reuse the same cursor but using a different facility. It just has data from another facility to graph. I do not recall the same query for the previous facility. SOrry if it was not clear.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I need to make myself clearer. I run the same cursor using the same syntax for one facility and graph its history. Then, I use the same cursor using the same syntax but of course the WHERE clause is for another facility. Does memory usage accumulate every time I run it for a facility if I do not close the cursor each time. Does running the cursor for another facility negates the memory used by the one run before it and so on. Also, can I estimate how much memory is being consumed when a cursor is executed.
I hope my question is self explanatory.
mahares
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
I need to make myself clearer. I run the same cursor using the same syntax for one facility and graph its history. Then, I use the same cursor using the same syntax but of course the WHERE clause is for another facility. Does memory usage accumulate every time I run it for a facility if I do not close the cursor each time. Does running the cursor for another facility negates the memory used by the one run before it and so on. Also, can I estimate how much memory is being consumed when a cursor is executed.
I hope my question is self explanatory.
mahares

If you have a rooted device (that works also with the emulator), you should use the DDMS tool provided with the Android SDK. It allows to see in real-time the memory allocation. It's very easy to use: you choose the device, you choose the process, you open the VM Heap tab and that's all.
 
Upvote 0
Top