.NET Blog

Tony Cavaliere

 
My Favourite Albums
  And the Grappa wins.
E-mail me Send mail
Add to Technorati Favorites AddThis Feed Button

Subscribe to Cynot Why Not


Recent posts

Disclaimer

Hey unlike other bloggers I stand by what I say but just in case. The opinions expressed herein are my own except on Tuesday when the second card is not turned up otherwise it ain't worth squat.

© Copyright 2010

Silverlight Image Control Memory Usage

I just noticed this while monitoring the browser memory usage while it was hosting a Silverlight image control. It appears that if you create a simple image control, with a modest size of 127KB, the total memory used by the browser increases by about 20MB.

Let me describe the scenario and perhaps you can try it out for yourself.

Create a simple Silverlight application and place a TextBlock on the page. The XAML should be similar to the listing below.

    1 <UserControl x:Class="ImageControlMemory.Page"

    2    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    3    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    4    Width="400" Height="300">

    5     <Grid x:Name="LayoutRoot" Background="White">

    6         <TextBlock Text="Is the silverlight image control a memory hog?" />

    7     </Grid>

    8 </UserControl>

Next bring up a tool that will allow you to monitor memory usage at the process level. I use SysInternals Process Explorer. Navigate to some site (I choose Google). Go back to the Process Explorer tool, find the Browser process and double click it. This will bring up the Process Properties window from which you can see the memory usage of the browser. You should see something similar to the figure below.

google usage

Browser memory usage when visiting Google.com.

Note that the memory usage for the browser (FireFox) is about 27MB.

Now navigate to the page that hosts the above Silverlight control. The memory usage in the Process Explorer should have increased by about 13MB. I assume that is a reasonable amount to host Silverlight. The memory usage when hosting this simple Silverlight control is shown in the figure below.

google textblock 

Browser memory usage with Silvelight control containing a text block control.

Now lets add an Image control to the XAML. But before you add the Image control you will need an image. The image I used is about 127KB. Go ahead find an image of similar size, add it to the Silverlight project and make sure it's Build Action is set to Resource. Next add the image control to the XAML. Your new XAML  should be similar to the listing below.

    1 <UserControl x:Class="ImageControlMemory.Page"

    2    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    3    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    4    Width="400" Height="300">

    5     <Grid x:Name="LayoutRoot" Background="White">

    6         <TextBlock Text="Is the silverlight image control a memory hog?" />

    7         <Image Source="image.jpg" />

    8     </Grid>

    9 </UserControl>

Start a new instance of the browser making sure there are no other instances running. Navigate to the google site and then navigate to the page that hosts the second Silverlight control. Now take a look at the browser's memory usage. It should be close to 60MB!  The Process Explorer display is shown below.

google image

Browser memory usage with Silvelight control containing an image control.

Let's recap when the browser is displaying a simple site such as google.com the memory usage is about 27MB. Next if we navigate to a site with a Silverlight control containing one TextBlock control the memory usage is about 40MB. Lastly, if we navigate to a site with a Silverlight control containing a TextBlock and an Image control (with a size of 127KB) then the size is around 60MB.

20MB just to display an image of size 127KB. What's going on?

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: Silverlight
Posted by CynotWhyNot on Thursday, October 23, 2008 2:53 PM
Permalink | Comments (17) | Post RSSRSS comment feed

Another Custom Silverlight Media Player?

I know there are countless custom Silverlight media players out there, but why not! I decided to roll my own as I thought it would be a good learning experience. There are plenty of interesting issues that need to be considered. How do you handle full screen mode, how about resizing and dragging. What about an animated dashboard that displays a timeline and VCR like buttons. Finally, the control should be written in such a way that you can host one or more play backs videos all by inserting some simple XAML to your page (of course you will need to reference the assembly containing the control).

Take a look at it in action. Below are two instances of the control each loading different videos (be patient it may take a while to buffer the content).

If you are interested in the code for this control then visit my Silverlight Gallery.  There you will be able to download the code.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: Silverlight
Posted by CynotWhyNot on Wednesday, October 22, 2008 4:05 PM
Permalink | Comments (23) | Post RSSRSS comment feed

Silverlight Gallery

Well it has finally arrived, Silverlight 2 RTM was officially release on Tuesday October 14. ScottGu and Method ~ of ~ failed have great posts on this release. The bits can be downloaded from silverlight.net.

I have been focusing my attentions on Silverlight and have written a considerable number of Silverlight demos. I finally sat down and thought about how I could package all these demos into a single site so that I could share my experiences with other Silverlight developers, hence, the CynotWhyNot Silverlight Demo Gallery.

The site contains two Silverlight controls; the first is used to list all the demos and the second used to host the actual demo. I wanted this site to be easily configurable and decide to use an XML file the drive the site. Basically, the XML lists the available XAPs. The first Silverlight control deserializes this  XML into an in memory object. The short description is used to populate the list box. When a menu item is selected a call to a javascript function is made which in turn sets the source attribute of the second Silverlight control.

I don't want to go into too much detail about the details of the gallery application as I will deal with that in a future post. For now just check it here. 

Currently I have seven demos installed. Each demo comes with a link where the entire source can be downloaded. Even the code for the gallery application can be downloaded.

I will be updated this gallery with new demos so be sure to visit again.

slgallery

Guess the movie

Why don't you stick around, Junior?  

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by CynotWhyNot on Wednesday, October 15, 2008 4:47 PM
Permalink | Comments (5) | Post RSSRSS comment feed

Summer's Over

It's getting colder. The flowers are no longer blooming. The leaves on the trees are beginning to change colour. Heck my garden on the balcony is beginning to die. No more basil, no more tomatoes which means no more fresh tomato basil salads. All these are indicators of the demise summer and the arrival of fall. Or are they?

.NET developers have there own ways of doing things and determining changes in the season are not necessarily determined by the means described above. The last user group meeting of the year tells us that summer is here. Likewise the first meeting tells use that fall has arrived and winter is just around the corner.

I just went to the first TVBUG meeting. A great beginning to a what is sure to be a great set of presentations in the up and coming user group sessions.

Here is a list of user groups in and around the Greater Toronto Area. Please visit their sites and check to see if there are any presentations that interest you. They are all free!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: User Group
Posted by CynotWhyNot on Friday, October 03, 2008 4:23 PM
Permalink | Comments (18) | Post RSSRSS comment feed