6

We are creating an app that syncs 5000 calendar entries with the server. The issue is that after adding 1913 entries it failing and giving the following stack trace. What is the problem?

12-30 11:48:16.989: DEBUG/dalvikvm(384): GC_EXPLICIT freed 5699 objects / 345848 bytes in 579ms
12-30 11:48:22.530: DEBUG/dalvikvm(232): GC_EXPLICIT freed 2552 objects / 124160 bytes in 311ms
12-30 11:48:24.560: ERROR/CursorWindow(232): need to grow: mSize = 1048576, size = 414, freeSpace() = 328, numRows = 1913
12-30 11:48:24.599: ERROR/CursorWindow(232): not growing since there are already 1913 row(s), max size 1048576
12-30 11:48:24.599: ERROR/CursorWindow(232): The row failed, so back out the new row accounting from allocRowSlot 1912
12-30 11:48:24.620: ERROR/Cursor(232): Failed allocating fieldDir at startPos 0 row 1912
12-30 11:48:27.340: DEBUG/Cursor(232): finish_program_and_get_row_count row 3266
12-30 11:48:28.070: ERROR/Calendar(Vikas)(384): Uncaught exception in EasSyncServicejava.lang.NullPointerException
12-30 11:48:28.089: ERROR/Calendar(Vikas)(384): Sync ended due to an exception.
Mark Byers
  • 811,555
  • 193
  • 1,581
  • 1,452
user558022
  • 61
  • 1
  • 2
  • Visit http://code.google.com/p/android/issues/detail?id=21435, maybe you are effected by the same problem –  Nov 01 '11 at 22:12

2 Answers2

6

The CursorWindow class only supports reading 1MB of data per query:

#define MAX_WINDOW_SIZE (1024 * 1024)

(Source)

Try one or more of the following:

  • Request fewer rows.
  • Request fewer columns.
  • Split your query up into smaller queries and run them one at a time.

One way you could improve the situation is to store the last sync date on the server and only synchronize changes that have happened since that date.

SELECT *
FROM calendar
WHERE modified > 'some date'
Mark Byers
  • 811,555
  • 193
  • 1,581
  • 1,452
  • ThanksBy default the application will sync only those events those are not synced but we have to give support for minimum 5000 calendar events. can u please share some code – user558022 Dec 30 '10 at 08:43
  • @user558022 You could add "LIMIT 500" to your query and only sync 500 events. Then once that is done run the sync again to get the next 500, etc... until you synced everything. – Mark Byers Dec 30 '10 at 08:47
  • thanks Mark, now what we are doing is calling a getCalendar method which returns one row each time it is called form the jni. after each call we are closing the cursor. but how its running out of memory. – user558022 Dec 30 '10 at 09:13
  • try cursor.releaseMemory() method – AZ_ May 18 '11 at 13:03
1

I had the same problem, in my case was due to a NullPointerException by parsing the TimeZone info (unfortunately the stack trace is lost in code).

Maybe you are affected by the same problem.

Visit http://code.google.com/p/android/issues/detail?id=21435, I've opened an issue by google but it looks like they are not interested to the problem. The Issue is currently Declined.