hack_soldier
Member
Hello everyone,
I'm working with a Cursor/ResultSet object. After I finish all the necessary operations, I call the .close() method on it, as is standard practice to release resources.
However, I've noticed that even after calling .close(), the variable holding the Cursor/ResultSet object is not null. If I inspect it, it still appears to be an initialized object and even retains some property values, like the RowCount > 0.
My understanding is that to fully release the object and ensure it's garbage collected, I should not only call .close() but also explicitly set the variable to null (e.g., myCursor = null). When I do this, the variable correctly reflects a non-initialized state.
My question is: Is this behavior by design? We need to execute both operation .close() and set = null? Can you suggest a correct use of Cursor/ResultSet object?
I've attached a small test project to this post that clearly demonstrates the behavior.
my development environment:
Thanks in advance for any insights!
I'm working with a Cursor/ResultSet object. After I finish all the necessary operations, I call the .close() method on it, as is standard practice to release resources.
However, I've noticed that even after calling .close(), the variable holding the Cursor/ResultSet object is not null. If I inspect it, it still appears to be an initialized object and even retains some property values, like the RowCount > 0.
My understanding is that to fully release the object and ensure it's garbage collected, I should not only call .close() but also explicitly set the variable to null (e.g., myCursor = null). When I do this, the variable correctly reflects a non-initialized state.
My question is: Is this behavior by design? We need to execute both operation .close() and set = null? Can you suggest a correct use of Cursor/ResultSet object?
I've attached a small test project to this post that clearly demonstrates the behavior.
my development environment:
- B4A Version: 13.40
- android.jar: 36
- Build Tools: 36.0.0
Thanks in advance for any insights!