I am getting the following errors on Database object that "supposedly"
hasn't been closed yet. I have a helper class that I use to retrieve the
Database (all db calls go through this class) and in it's finalize I call
close() on the db. you can see from my log that it is being called.
Interestingly if I sprinkle my code with System.gc() I never get the
warnings, only my Created/Finalized messages.
I'm not sure what I am doing wrong
>
> MySQLiteDatabase Created:com.myapp.db.MySQLiteDatabase@7e9eb29
>
> MySQLiteDatabase Created:com.myapp.db.MySQLiteDatabase@35618bac
>
> MySQLiteDatabase Created:com.myapp.db.MySQLiteDatabase@5d07ff0
>
> **** WARNING! Database object was released by the GC without being closed
>> first! This might cause crashes on iOS *****
>
> MySQLiteDatabase Finalized:com.myapp.db.MySQLiteDatabase@5d07ff0
>
> MySQLiteDatabase Finalized:com.myapp.db.MySQLiteDatabase@35618bac
>
> **** WARNING! Database object was released by the GC without being closed
>> first! This might cause crashes on iOS *****
>
> MySQLiteDatabase Finalized:com.myapp.db.MySQLiteDatabase@7e9eb29
>
>
Here is the class that I use to wrap all my db calls:
public class MySQLiteDatabase extends Object {
protected Database db = null;
public void setDb(Database db) {
this.db = db;
}
public MySQLiteDatabase() {
System.out.println("MySQLiteDatabase Created:" + this);
}
protected void finalize() throws Throwable {
System.out.println("MySQLiteDatabase Finalized:" + this);
try {
db.close();
} catch (IOException e) {
e.printStackTrace();
}
}
... }
Peter
--
You received this message because you are subscribed to the Google Groups
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit
https://groups.google.com/d/msgid/codenameone-discussions/92385781-756b-415b-b889-82b2b8a6a2e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.