Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Kevin Haube
12,265 PointsParse.com Queries & Memory Management?
UPDATE: Good news! Another user has filed this exact bug with Parse. It appears as though it's on their end. Hoping the bug is fixed ASAP!
I'm creating a fun trivia game, and my app is heavily based off of Parse.com's back-end. I have Quiz, Question, Answer, and Category classes on the back-end, all of which are queried in my code many times. Though there seems to be a problem... after 8 to 10 queries, things don't work anymore. i can't figure out if the queries are triggering, or if the reults are being returned, but I do have a few possible ideas as to what might be happening.
My first thought was poor memory management, because the queries gradually get slower and slower with each call, but I don't have the slightest clue what to do about it. Each time a getQuery() is called, I store the value in a ParseObject variable, and each time a new Intent is launched, I'm usually passing it one or more extras, in the form of objectIds. I assume that takes up a solid chunk of memory, though my app's Cache begs to differ. It's relatively low when I check it.
Now, I have ruled out the possibility of it being an issue with the app not having correct info. Each time an Activity is loaded, the app has the correct ID to call queries with. I've also eliminated the possibility of it being a cap on my free parse account. I average about .2 req/s when running this vigerous test on my application.
If you want to look at the source code, due to it's complexity and length, I'll have it hosted on GitHub instead of in a codeblock here.
This is by far the most perplexing bug I've had to date.
EDIT: By using Log.v calls, I've determined that the Parse queries do, in fact, get called, but never finish after having called a few. Could still be a result of memory issues, because my Parse account shows my calls not reaching anywhere near the limit.
1 Answer
Ben Jakuben
Treehouse TeacherI downloaded your code and played around with it a little but it seems to be communicating with Parse fine. Can you detail some steps to take to recreate the slowdown?
Kevin Haube
12,265 PointsKevin Haube
12,265 PointsI usually put it through the ringer by going into the QuizProfileActivity, and back out to the QuizList over and over again. It also works between QuizProfile and the EditQuiz activities. I'm not sure if you have the version where I used the Log statements, but if you want to go ahead and put some in before and after the queries, you'll see that the last one will start, but never finish...but also won't return an error (my newer code has implimented the error catch but it turns up nothing).
Ben Jakuben
Treehouse TeacherBen Jakuben
Treehouse TeacherOne thing I noticed was that you are calling getQuestions() twice in QuestionListFragment - once in onResume() and once in the callback of getQuiz.getInBackground(). Removing the extra call helps a little. I just moved everything into onResume:
Otherwise it looks like Parse is communicating slowly. I wish I had a better answer, but I've seen and heard of slow calls before. Supposedly doesn't have anything to do with using a free account, but it's a shame that it's running so slowly right now.