简体   繁体   中英

Codename One treating label text as string literal in iOS?

The app that I've built it a journaling app, and users can go back and look at their previous entries from a calendar page (screenshot attached). On iPhone only (Android is fine), after clicking through about 20 days the app crashes. It doesn't send a crash message through email, so I'm pretty sure that it's hitting a memory limit.

In testing, I kept all of my logic the same and only removed the part where I generate the spanlabel to show the journal text. I was still pulling the text from the database, just not creating the label and displaying it. And it stopped the crashing.

So my question is, is there anything I can do to make sure that the text that goes into the label does not get stored in memory, so that the garbage collector can remove it?

在此处输入图片说明

Are you sure you're closing the DB from the "right thread"? iOS is super sensitive about the thread used for DB access. Also make sure you close the cursor first and the DB after if you do close it.

I suggest reproducing this on the simulator by placing a breakpoint in the cursor close() method and seeing who invoked it. If our finalizer method reaches the cursor then you have a bug of leaving an open cursor somewhere that you can reproduce in the simulator. At this point you can log every cursor opening then see which cursor wasn't cleaned up. Make sure all cursor openings are coded defensively with a finally block.

I've found the problem is caused when several really small queries run consecutively. After removing those the larger queries run without crashing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM