PDA

View Full Version : Checking for/fetching new data every x minutes, memory problem?




fishkorp
Dec 1, 2008, 07:32 AM
I'm working on something where the app will fetch data from a URL and populate a table with the results. I'm trying to get it to fetch if the app is open at an interval (say every 10 minutes for this example). I have that all setup using an NSTimer and it works. My issue is memory. I'm not sure what I should be releasing or reallocating and when. On my dev phone I installed the program, opened it up, and just let it run. After a while (hours) it crashes, I'm assuming out of memory (didn't check the log yet, I had to leave and I don't have access to the phone or XCode until later today). The current flow is:

Open app->makes request->parses response->populates table.

Every 10 minutes it will remake the request->parse response->populate table if response is different.

I'm assuming I'm missing something very simple? Are there any Apple provided examples that do something similar that I missed?



caveman_uk
Dec 1, 2008, 07:45 AM
Use instruments to see if you're leaking memory when you update.

fishkorp
Dec 1, 2008, 06:51 PM
Looking at what's happening, I'm (inadvertently) calling the scheduledTimerWithTimeInterval every time through :eek: So first time it repeats after x minutes, next time it repeats twice, then three times, etc. Can easily make a crash like that, lol.