OutOfMemory dispaying lots of markers with custom icon?

Topics: Help
Aug 20, 2013 at 5:17 PM
Hello all,

I have a layer that displays thousands of markers and I am using a 4k sized custom bitmap (.png) for the icon but everytime I try to display the layer, I get an OutOfMemory error.

I set up the map so that the layer only display when zoomed in at level 7 or higher but it still gives me the error.

Is there any other way to approach this or am I limited to just using a stock Google icon in my situation?

Thanks in advance.
Aug 24, 2013 at 4:55 AM
Since I know how frustrating it is to search for a solution to a problem and find none, here is how I fixed my problem, in case someone runs into the same issue:

Instead of calling the bitmap INSIDE a foreach or while loop such as this:
GMarkerGoogle vorMarker = new GMarkerGoogle(new PointLatLng(Convert.ToDouble(vor["lat"]), Convert.ToDouble(vor["lon"])), new Bitmap(ImagesFolder + @"\\gmaps\\intersection.png"));
I simple set an icon variable BEFORE calling the loop such as this:
Bitmap icon = new Bitmap(ImagesFolder + @"\\gmaps\\intersection.png");
Then inside the loop, I call the bitmap like this:
GMarkerGoogle vorMarker = new GMarkerGoogle(new PointLatLng(Convert.ToDouble(vor["lat"]), Convert.ToDouble(vor["lon"])), icon);
Now I was able to load over 50,000 markers WITHOUT A HIT in memory :-)
Coordinator
Aug 24, 2013 at 7:16 AM
it's called object reusing, common practice in .net
Aug 24, 2013 at 8:31 AM
Edited Aug 24, 2013 at 8:32 AM
Common for those that know how to program in .NET, unlike me, who has to resort to asking these questions and end up having to find the answer on my own. Which I don't mind because that's how one learns, but if you knew that was the way to go, a little nudge before the fact would've help immensely.