如果你分析下面的代码,你会看到有4个函数被多次调用(pushNextEntityUpdatedRows,pushNextUpdatedRow,pushNextEntityCreatedRows,pushNextCreatedRow),这不是一个BUG,这就是我如何设计我的代码来工作。你应该知道的是我有一个扩展 SQLiteOpenHelper 的类(DataAccess),我只将该类实例化一次。每次调用函数 pushNextEntityUpdatedRows 和 pushNextEntityCreatedRows 时,都会在我的DataAccess类实例中执行rawQuery。我从不关闭连接,我只关闭Cursor对象实例。我不知道造成这个 StackOverflowError 的原因是什么。我也不知道为什么它总是在145次调用之后发生。我该如何解决?谢谢你的到来。
堆栈跟踪告诉我:
java.lang.StackOverflowError
at java.util.WeakHashMap.poll(WeakHashMap.java:550)
at java.util.WeakHashMap.put(WeakHashMap.java:589)
at android.database.sqlite.SQLiteConnectionPool.finishAcquireConnectionLocked(SQLiteConnectionPool.java:980)
at android.database.sqlite.SQLiteConnectionPool.tryAcquirePrimaryConnectionLocked(SQLiteConnectionPool.java:916)
at android.database.sqlite.SQLiteConnectionPool.waitForConnection(SQLiteConnectionPool.java:682)
at android.database.sqlite.SQLiteConnectionPool.acquireConnection(SQLiteConnectionPool.java:400)
at android.database.sqlite.SQLiteSession.acquireConnection(SQLiteSession.java:905)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:586)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1436)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1375)
at mz.co.cloud.dumbo.db.LSH.getAllNewCreatedRows(LSH.java:2072)
at mz.co.cloud.dumbo.syncmechanism.SyncDataAccessImplementation.getAllNewCreatedRows(SyncDataAccessImplementation.java:182)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityCreatedRows(SyncWorker.java:1039)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1355)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityCreatedRows(SyncWorker.java:1046)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1355)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityCreatedRows(SyncWorker.java:1046)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1355)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityCreatedRows(SyncWorker.java:1046)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1355)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityCreatedRows(SyncWorker.java:1046)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1355)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityCreatedRows(SyncWorker.java:1046)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1355)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityCreatedRows(SyncWorker.java:1046)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1355)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityCreatedRows(SyncWorker.java:1046)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1355)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityCreatedRows(SyncWorker.java:1046)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1355)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityCreatedRows(SyncWorker.java:1046)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1355)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityCreatedRows(SyncWorker.java:1046)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1355)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityCreatedRows(SyncWorker.java:1046)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1355)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityCreatedRows(SyncWorker.java:1046)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1355)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityCreatedRows(SyncWorker.java:1046)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1355)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityCreatedRows(SyncWorker.java:1046)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1355)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityCreatedRows(SyncWorker.java:1046)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1355)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityCreatedRows(SyncWorker.java:1046)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1355)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1169)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1154)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityCreatedRows(SyncWorker.java:1046)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextCreatedRow(SyncWorker.java:1355)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityCreatedRows(SyncWorker.java:1046)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityUpdatedRows(SyncWorker.java:714)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextUpdatedRow(SyncWorker.java:1020)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityUpdatedRows(SyncWorker.java:704)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextUpdatedRow(SyncWorker.java:1020)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityUpdatedRows(SyncWorker.java:704)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextUpdatedRow(SyncWorker.java:1020)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityUpdatedRows(SyncWorker.java:704)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextUpdatedRow(SyncWorker.java:1020)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityUpdatedRows(SyncWorker.java:704)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextUpdatedRow(SyncWorker.java:1020)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityUpdatedRows(SyncWorker.java:704)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextUpdatedRow(SyncWorker.java:1020)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityUpdatedRows(SyncWorker.java:704)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextUpdatedRow(SyncWorker.java:1020)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityUpdatedRows(SyncWorker.java:704)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextUpdatedRow(SyncWorker.java:1020)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityUpdatedRows(SyncWorker.java:704)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextUpdatedRow(SyncWorker.java:1020)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityUpdatedRows(SyncWorker.java:704)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextUpdatedRow(SyncWorker.java:1020)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityUpdatedRows(SyncWorker.java:704)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextUpdatedRow(SyncWorker.java:1020)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityUpdatedRows(SyncWorker.java:704)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextUpdatedRow(SyncWorker.java:1020)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityUpdatedRows(SyncWorker.java:704)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextUpdatedRow(SyncWorker.java:1020)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityUpdatedRows(SyncWorker.java:704)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextUpdatedRow(SyncWorker.java:1020)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityUpdatedRows(SyncWorker.java:704)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextUpdatedRow(SyncWorker.java:1020)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityUpdatedRows(SyncWorker.java:704)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextUpdatedRow(SyncWorker.java:1020)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityUpdatedRows(SyncWorker.java:704)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextUpdatedRow(SyncWorker.java:1020)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityUpdatedRows(SyncWorker.java:704)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextUpdatedRow(SyncWorker.java:1020)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityUpdatedRows(SyncWorker.java:704)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextUpdatedRow(SyncWorker.java:1020)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityUpdatedRows(SyncWorker.java:704)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextUpdatedRow(SyncWorker.java:1020)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityUpdatedRows(SyncWorker.java:704)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextUpdatedRow(SyncWorker.java:1020)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityUpdatedRows(SyncWorker.java:704)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextUpdatedRow(SyncWorker.java:1020)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityUpdatedRows(SyncWorker.java:704)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextUpdatedRow(SyncWorker.java:1020)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushNextEntityUpdatedRows(SyncWorker.java:704)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.pushData(SyncWorker.java:678)
at mz.co.cloud.dumbo.syncmechanism.SyncWorker.startWork(SyncWorker.java:197)
at mz.co.cloud.dumbo.syncmechanism.DumboSync$1.onMessage(DumboSync.java:213)
at com.pier.PierClient$1.run(PierClient.java:268)
at com.pier.core.WorkQueue$PoolWorker.run(WorkQueue.java:81)
答案 0 :(得分:2)
看起来你有一个循环或递归函数,它没有到达循环/函数的中断/结束。大多数情况下,当您使用if语句检查递归函数的结尾时,它实际上永远不会更改if语句的条件。在某些时候,你的计算机没有足够的“思考空间”进一步沿着兔子洞走下去。 (因为每次迭代占据整个空间的某个部分,以简单的方式说出来。显然,在145次迭代中,你已达到极限)
没有我们在这里无法帮助您的代码,如何添加示例代码?