High CPU usage with Map

Oct 8, 2009 at 10:57 AM

Hi

I have an Silverlight 3 application that normally uses less than 10% or CPU, when I open the map (without show application data yet, only shows the map) the CPU usage goes to more than 90% (I don't move the mouse) an the application works very slow, when I close the map returns to lower values. I tries with IE6, IR7, Firefox 3.5.3 and Silverlight Out of Browser Mode.

Is the map does anything in the background?, how I can reduce le CPU usage?.

Thanks.

Alejandro

Coordinator
Oct 8, 2009 at 11:16 PM

While fetching tiles the underlying MSI control consumes as much CPU as it can to give you the best experience, once the tiles are loaded it goes down to 0%.

However I have seen many issues that also cause high CPU:

  1. Using the ImplicitStyleManager the map seems to continuously cause it to rescan the visual tree, set it to ApplyOnce.
  2. Using custom tiles you get a 404 error, the map just keeps on asking for it. I setup a tile handler in the middle and return a blank tile instead.
  3. Using an animation on a custom pin, then adding hundreds of these pins. Better off using a Sprite instead.

 

Here are a few other tests you can try that get 0% usage on my computer after loading:

Simple Bing Maps with DeepEarth controls: http://about.soulsolutions.com.au/

The original DeepEarth Map: http://deepearth.soulsolutions.com.au/

Lutz' custom exact rendering demo for layers: http://msbluelight-0.agappdom.net/e1/d/74675/23345948/63390729600/0.TQPJ0kBEsKbtKHI0kmwDqlLC1qA/zziframehtml2zz.html#%2f%2fappId%2fDeepZoomProject.xap%2fblack%2ffalse%2f%2f%2f%2f%2ftrue%2f3.0%2f0

(These three are all very different map renderings in Silverlight all using the MSI)

Nov 6, 2009 at 5:09 PM

soulsolutions said:Using custom tiles you get a 404 error, the map just keeps on asking for it. I setup a tile handler in the middle and return a blank tile instead.

how to do it ?

Coordinator
Nov 7, 2009 at 8:48 PM

Turns out the mst likely casue of the high cpu is an animation running at high frame rate, the MSI control will also doa full resdraw in time with the animation. MSFT are working to fix this.

To create your own tile hander use a "generic handler" .ashx file template in Visual studio. Read in the parameters as per an ASP.NET but set the responce type to your image type and server back your tile, where no found server back a 256x256px PNG completely transparent.

private const string BLANKTILE = "~/tiles/blank.png";

        private static void serveBlankTile(HttpContext context)
        {
            context.Response.Cache.SetExpires(DateTime.MinValue);
            string blanktile = context.Server.MapPath(BLANKTILE);
            using (Image img = Image.FromFile(blanktile))
            {
                using (var stream = new MemoryStream())
                {
                    img.Save(stream, ImageFormat.Png);
                    stream.WriteTo(context.Response.OutputStream);
                }
            }
        }