在创建新结果集之前,我是否必须在 Titanium Mobile 中关闭结果集,或者一旦没有引用它就会自动“关闭”?
例如,这样的东西是否安全且无内存泄漏?
var db = db.open("db_name");
var rs = db.execute("SELECT * FROM table");
while(rs.isValidRow()){ /* working with the resuls... */ }
// I make another select before closing the previous (current) results set
rs = db.execute("SELECT * FROM another_table");
while(rs.isValidRow()){ /* working with the results... */ }
// Once I am completely done I close the RS and DB
rs.close();
db.close();
或者,每次需要新选择时,我都必须关闭结果集。
var db = db.open("db_name");
var rs = db.execute("SELECT * FROM table");
while(rs.isValidRow()){ /* working with the resuls... */ }
// Close RS and then initialize a new one
rs.close();
rs = db.execute("SELECT * FROM another_table");
while(rs.isValidRow()){ /* working with the resuls... */ }
rs.close();
db.close();