01 Feb 2010 @ 8:30 AM 
Bookmark and Share

The impact of performance is much more readily apparent in .NET Compact Framework applications.  The mobile devices commonly have a CPU that is 10 times slower than your desktop CPU, and possibly up to 100 times less RAM than a desktop or server.  In Agile or XP development, the mantra is often to ignore performance considerations until necessary – I don’t think you can apply that to .NET CF development or it will really bite you in the end.  You don’t have to go nuts and optimize everything up front, but there are some very important things to keep in mind when developing a Windows Mobile application…

Standard .NET Framework Performance Considerations

Many of the standard .NET Framework performance best practices can become apparent very quickly including…

  • Object Boxing and Unboxing.  Use generics wherever possible and avoid ArrayLists and type conversions.
  • String and StringBuilder.  Need to perform lots of string concatenations? Use a StringBuilder instead of the ‘+’ operator.  When you use the ‘+’ operator, a new string object is created each time you concatenate, increasing memory usage.  The ‘+’ operator is much slower if you’re concatenating a large number of strings.
  • Memory leaks.
    • When doing .NET CF development, if an object implements the Dispose() method – call it when you are finished with the object.
    • One of the most common causes of memory leaks is unhandling events when they’re no longer needed.  If you manually hook up an event with the ‘+=’ operator, ensure you’re unhandling it when finished with the ‘-=’ operator.
    • Pre-allocate collections if possible.  Standard .NET behavior is to automatically double the size of a collection when the upper limit is reached while adding items.  If you know the number of elements that are are going to be in a collection, pre-allocate the size of the collection when instantiating it.
  • Don’t use Exceptions for flow control in an application.  Exceptions are an expensive operation, performance wise.  I’m not saying don’t use exceptions, but don’t use them in areas where you can perform simple checks to prevent them from being thrown.  For example, if you might divide by zero – perform a simple check before the operation occurs rather than handling a DivideByZeroException.  The check is much less expensive than the exception.

.NET Compact Framework-Specific Performance Considerations

However, the .NET Compact Framework is different than the full framework in many ways, leading to a slew of .NET CF specific performance considerations…

  • Avoid making virtual function calls.  They are up to 40% slower than instance and static function calls.  I don’t completely understand the reason for this, but you can read more about it here if you’re interested.
  • There are a few things in .NET CF that are slow because of virtual calls and object boxing/unboxing.  These include:
    • Reflection.  Very slow in .NET CF.
    • XML Deserialization and DataSets.  Extremely slow  because reflection is slow.
  • Avoid creating many copies of Form objects.  Creating a Form is an expensive operation, and unused Form objects are a common cause of memory leak issues. You may want to create your Forms once and cache them in the background for reuse.
  • You can increase the speed of binding data to controls by using the BeginUpdate and EndUpdate methods on a control before and after your data binding occurs.  This will cause the control to not repaint until the binding is finished.
  • Cache expensive resources.  For example, don’t create many different copies of a web service client.  Create a single, cached instance of it that can be used throughout your application.
  • Always test your application on a wide range of physical devices.  If the target device is known, at least test on that device.  Some things seem to perform much betterwhen running on the emulator or when executing unit tests on your desktop environment.
  • This is a more general performance testing best practice, but always test with real data and real quantities of data. This can really bite you on deployment of your application.  I know this from experience – a great example is that deserializing a few hundred objects is MUCH much faster than deserializing 10,000 objects.  In my experience, deserializing 7,000 very simple DTO objects from an ASMX web service was taking up to 20 minutes in some cases.  To alleviate the issue, we ended up switching to a JSON web service, which was much faster to deserialize.
Posted By: admin
Last Edit: 08 Feb 2010 @ 09:34 PM



Responses to this post » (9 Total)

  1. Canon 5D Mark III on amazon…

    System.Nerd.John.Blog » Blog Archive » .NET CF and Windows Mobile Performance Best Practices…

  2. svejo.net says:

    Clean up any spilled oil and pour the used oil
    in a container to drop off at your local recycling center.
    What could be more convenient and good for your vehicle and your wallet than a once
    a year oil change. So, for instance, if the manufacturer said you could use 10w30 or 10w40 in your vehicle, unless your application falls under one of the exceptions below, you could safely stick to
    an Xw30 oil (using the lowest “Y” value listed) and you could go with a 0w30 or 5w30 oil safely, even though the
    manufacturer listed only 10w options.

  3. It’s an remarkable article for all the online
    people; they will obtain advantage from it I am sure.

  4. Have you ever thought abiut adding a little bit more than just your articles?
    I mean, what you say is immportant and all. However think of if yoou added some great pbotos
    or videwo clips to give your posts more, “pop”! Your content is excellent but with pics
    and videos, this site could certainly bbe one of the very best in its niche.
    Awesome blog!

    Feell free to visit my site … SEO Hertfordshire

  5. Jett says:

    I read a lot of interesting content here. Probably you spend a lot
    of time writing, i know how to save you a lot of
    time, there is an online tool that creates unique,
    SEO friendly posts in minutes, just type in google – laranitas free content

  6. tire pyrolysis machine, waste oil pyrolysis machine, Waste tires oil
    refining equipment, waste tire to fuel machine, pyrolysis machine,
    pyrolysis machine buyer, waste rubber recycling to oill machine, Waste tire recycling machine, waste plastic refinery to oil plant, worlds best waste tyre pyrolysis machinery manufacturers, waste tires pyrolysis to oil
    plant, rubber pyrolysis plant, waste oil refinery machine, rubberr pyrolysis machines,
    waste tyre plant, waste plastic refining, Waste Oil Refining Plant, waste tjre
    pyrolysis plant, hi tech waste oil recycling, trrye pyrolysis machine, waste plastic pyrolysis machine, Waste tyre pyrolysis plant, complrte pyrolysis plant equipment, Waste Plastic Recycling Machine, waste
    tire recycling plant, tire pyrolysis oil distillation machine
    to diesel, plastic pyrolysis oil distillation machine to diesel, oil
    from waste tyre machine manufacturer, turn waste tire to oil,
    pyrolysis plant foor tire recycling, tyre pyrolysis plant,
    waste ooil distillation equipment, used oil refinerey machine,
    used oil recycling machine, waste tyre recyclihg machine, sxrap tyres recycling
    to oil system, used plastic to furnace oil equipment, pyrolysis plant for
    rubber recycling, Waste tyre recycling plant, waste
    tyre pyrolysis, waste tyre recycling plant, waste pyrolysis
    plant, pyrolysis plant uk, used engine oil recycling machine, tire
    pyrolysis plant, wase tyre oiil plant 2014, waste engine oil diedsel machine, equipment requireed for
    pyrolysis plant for plastic waste, waste engione oil recycling to diesel machine, waste
    tyre refining equipment, tire to oil, waste tyre recycling, waste tire preocessing machine, tyre pyrolysis machone seller, waste tyrfe recycling machine, oil distillqtion machine, pyrolysis
    pant for plastic recycling, the best of waste tyre
    pyrolysis plant, tyre recycling pyrolysis plant,
    waste ploastic to oil machine, waste tyre,automatic plastic pyroklysis
    plant, pyrolysis tyre recycling plant, used tires to ooil machine,
    tyre pyrolysis oil, pyrolysis plant, tyrfe pyrolysis, wastee tire to diesel machine, tyre recycfling tto oil, waste
    tyre recycling pyrolysis plant china, tyre to diesel solution,
    waste plastic pyrolysis plant, tife pyrolysis plawnt usa,
    tire recycling to oiil supplier, Oil refining
    equipment, plastic pyrolysis plant, waste to oil plant, waste tire recycling too diesel, waste oil recycling plant, pyrolysis plant
    in gujarat, used oil recycling equipment, pyrolysis macchine
    manufacturers, pyrolysis machines for sale, scrap tires recycling machine, waste plastic to fuel machine, pyrolysis plants, car oil recycle machine, oiil
    refining machine, tide pyrolysis plant manufacturers, tyre pyrolisys plant,
    rubber recycling machine, other rubber recycling machines, pyrolysis of waste tyres, waste oil recycling to diesel, chinese tyre recyclin plant, tire recycling
    equipment, distillation machine, rubber recycling machines, cheap used plastc recycing machines, euroopen tyre recycling
    plant manufacturer, how to recycle used motor oil, machine for converting of waste plastic into oil, machine which converts waste plastic to oil, plastic film recycling machine, plastic recycling equipment
    south africa, small pirolisys plant, plastic recycling machines manufacturers, waste to enerty pyrolysis,
    pyrolysis plant india, machine for rcycling plastic bottles, smll scale plastic recycling plant, pyrolysis fuel oil, pyrolysis oil, pyrolysis
    plant forr sale, continuous pyrolysis plant, car oil recycling,
    conversion of pyrolysis oil to diesel plant, dispowal of wazte engine oil, engine oil recycling,
    equipment for distillation, oil recyclingg plant suppliers, recycle enine
    oil, reuse of waete engine oil, waste oil reclamation equipment, waste oil recycling system, waste oil refining, easiest way
    to recycle used oil, how to recycle used egine oil, recycle
    used oil, oil rrefining system, tire to diesel production line, plastic to diesel production line, crap plastic to
    oil machine, recycling plastic to fuel oil,
    convert plastic to oil system, scrap to oil machine, ploastic to ooil machine,
    waste plastic to diesel, waste to energy, waste to
    fuel, tire to fuel,used oil recyccling plant, waste oil to diesel machine, tire oil extraction machine,
    plastic oil extration plant, get oil from waste, pyroilysis plant manufacturer, waste oil to diesel plant, engine oil
    to dissel system, waste recycling machine, scrap recycling plant,
    tire oil to diesel, plastic oil too diesel, waste plastic processing to oil, crude oil refinery machine, usd tire recycling plant,
    paper offcut rcycling machine, tyre recycping machine, plastic waste recycling!
    It’s an excellent project, I came to know about
    this project thfough my friend. Convert wastes
    to wealth, renewable alternative resources, comke to see Huayikn waste tyre pyrolysis plant, supply waste tires/plastics
    pyrolysis plant and used oil distilloation plant to worldwice
    Focus on customer success! Heaad on to find it.

  7. weight loss says:

    Great articles you post here, i have shared this article on my

  8. As with everything there are risks involved with chiropractic treatments.
    Finally, your hormones and body changes have some effect too.
    One type can be what is called “Passive physical therapy” such services as heat and ice is used.

  9. Tammara says:

    The fitter should take the opportunity to explain what to look for
    so far as fitting is concerned, when buying a bra.

Post a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Change Theme...
  • Users » 3
  • Posts/Pages » 16
  • Comments » 163
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight


    No Child Pages.