Tag Archives: Memory overflow

Cursor window allocation of 2048 kb failed


cannot create Cursor because the system is out of memory. The following is the block of code

that is in question

public void insertCBJL(ArrayList<CBJLBean> cbjlList) {
        if (cbjlList.size() > 0) {
            mysql.beginTransaction();
            for (CBJLBean bean : cbjlList) {
                Cursor cursor = mysql.rawQuery(
                "select * from cbjl_table where yhh=?", 
                new String[] { bean.getYhh()});
                if (cursor.getCount() > 0) {
                    continue;
                }
                mysql.execSQL("insert into     cbjl_table(cbcid,...,scsyql) values (?,...,?)",
            new Object[] { bean.getCbcid(),...,bean.getScsyql() });
            }
            mysql.setTransactionSuccessful();
            mysql.endTransaction();
        }
    }

After the

for loop, there is a query statement that was originally inserted into the database in order for the data to be repeated. However, there is a big mistake. After being used, it is not closed, which causes the memory overflow.