0

I do my reading of lat, long etc values using the Open CSV reader - as I read somewhere that this is faster than using Buffered InputStream Reader? (Is that true?).

This reading happens in the "doInBackground" method of the AsyncTask. From the resulting array, I call the on "onProgressUpdate" method where I call a method to draw these markers on the Google Maps instance.

I also have marker clustering implemented, which is called while this is being done. As you know I need to call the array of items (marker data) one more time to send it as input to the ClusterManager class. Then, in "onPostExecute", I simply display a toast saying the loading is complete.

When I supplied about 5000 markers, I get a Memory out of bounds exception! But, I have to display about 10000 overall.

Now, the question is what are the ways to make this processing much faster and efficient, while keeping the CSV file. Please tell me if threading can be used anywhere during this process (I am new and don't know much - so clarity is of essence).

Tim B
  • 40,716
  • 16
  • 83
  • 128
Zac1
  • 208
  • 7
  • 34
  • 'From the resulting array,'. Are you putting 10000 coordinates in an array? – greenapps Nov 30 '15 at 08:19
  • Yes, separate array lists for lat, long, and name and each with a size around 10000. – Zac1 Nov 30 '15 at 16:12
  • I've clustered the markers, so It's not dense. The problem is loading them all from a text file, creating arrays, and loading them all as map markers. – Zac1 Dec 01 '15 at 04:44

1 Answers1

0

Threading will not help you here, as the reading of the file and/or the adding markers to the map will be your bottlenecks and your file access will if anything be slower if tried to do multiple times.

For the memory problems you need to profile your program and see what's using the memory. It may be that 5000 markers just uses too much memory, but also perhaps you have a memory leak or are doing something like reading and keeping the whole file in memory and could be more efficient in how you are processing it.

(Yes memory leaks can happen in Java, although it does protect you from some of the most common causes).

Tim B
  • 40,716
  • 16
  • 83
  • 128
  • I also have an array of marker items to display them one by one on the Google Map as a cluster in a For loop - Could I spawn one thread per marker there? – Zac1 Nov 30 '15 at 16:38
  • Maybe. I doubt it's recommended though. Google maps would need to synchronize the changes internally so how parallelizable the operation is is hard to estimate.... mobile phones generally don't have huge numbers of cores either. – Tim B Nov 30 '15 at 16:40
  • I think this is a real case where you need to work smarter, not harder. Get the number of markers down (5000 is too many to view on the screen anyway) and send the ones that actually matter. – Tim B Nov 30 '15 at 16:40
  • I've been looking for a way to "load" only the markers in the visible section of the map. However, I don't know how to do it. Are there any samples? – Zac1 Nov 30 '15 at 16:49
  • Try google. You need to look at your requirements and your data, and work out how to do it. We can't do it for you.... – Tim B Nov 30 '15 at 16:52