This is a mirror of official site: http://jasper-net.blogspot.com/

Profiling an application with Visual Studio – Memory allocation

| Wednesday, July 28, 2010
I discussed the possibilities of CPU sampling and instrumentation data collection in the previous articles and now it is time to benchmark the application performance indicators that target the memory.

To test this feature out, I created another sample application. This time, it works with files and I tried to create a simulation of a memory-consuming process.

The setup
It is a simple C# Console Application with only one method – Main. All the code is executed inside that method and no calls to external libraries are made. Here is what it looks like:

using System;
using System.IO;

namespace ConsoleApplication
{
   class Program
   {
       static void Main(string[] args)
       {
           string[] fileList = Directory.GetFiles(@"D:\Temporary");

           foreach (string file in fileList)
           {
               Console.WriteLine("Getting bytes for " + file + "...");
               Console.WriteLine("Bytes for " + file + ": " + File.ReadAllBytes(file).Length);
           }

           Console.Read();
       }
   }
}

What this code does is it gets the file paths (given a specific source folder) and then reads the file contents for each file separately to a byte array. For large files, this process will allocate quite a bit of memory, so that is a perfect way to demonstrate the capacities of built in profiling tools when it comes to memory allocation benchmarking.

As you can see from the code I am showing here, I am referencing a path that points to a folder called Temporary. To test it out, I copied a set of small and not so small files over there (a bunch of large texture files and a movie). And that is pretty much everything that is needed to simulate intensive memory consumption.

Trying it out – getting and analyzing the results
To start the process, go to Analyze > Launch Performance Wizard and select .NET Memory Allocation (Sampling)

Read more: DZone

Posted via email from .NET Info

12 comments:

Anonymous said...

Ahaa, its nice conversation about this paragraph at this place
at this weblog, I have read all that, so now me also commenting here.


Take a look at my site; global forex trading

Anonymous said...

You made some decent points there. I checked on the web for more information about the issue and
found most people will go along with your views
on this web site.

Here is my web page :: binary options

Anonymous said...

Quality articles or reviews is the main to be a focus for the people to visit the website, that's what this web page is providing.

Here is my site - exercises to jump higher

Anonymous said...

Hey very nice blog!

Also visit my web blog; exercises for vertical

Anonymous said...

Hey there I am so glad I found your blog, I really found you by error, while
I was browsing on Askjeeve for something else, Anyways I am here now and would just like to say thanks a lot for a incredible post and a all round entertaining blog (I also love the theme/design), I don’t have time to look over it all at the
minute but I have saved it and also added your RSS feeds, so when I have time I will be back to read much more,
Please do keep up the fantastic jo.

Here is my weblog: exercises To improve vertical leap

Anonymous said...

Hey there! I'm at work browsing your blog from my new iphone 4! Just wanted to say I love reading your blog and look forward to all your posts! Carry on the fantastic work!

Here is my website: exercises for vertical jump

Anonymous said...

Link exchange is nothing else however it is just placing the other person's weblog link on your page at appropriate place and other person will also do same in favor of you.

my blog post: http://wiki.mmizuki.dyndns.org

Anonymous said...

Terrific work! That is the type of information
that are supposed to be shared around the web.
Disgrace on Google for no longer positioning this post higher!
Come on over and consult with my website . Thanks =)

Stop by my web page; klaniny.pl

Anonymous said...

Everything is very open with a precise clarification of the issues.
It was definitely informative. Your website is useful.
Many thanks for sharing!

My site; vertical leap workouts

Anonymous said...

I got this site from my buddy who told me regarding this website and now this time I am browsing this site and reading very informative articles or reviews
here.

Look at my blog post exercises to increase vertical

Anonymous said...

We stumbled over here by a different web page and thought I might as well check things out.
I like what I see so now i am following you. Look forward to exploring your web page for a second time.


Have a look at my homepage - workouts to improve vertical

Anonymous said...

Does your site have a contact page? I'm having trouble locating it but, I'd like to send you an email.
I've got some recommendations for your blog you might be interested in hearing. Either way, great blog and I look forward to seeing it develop over time.

Also visit my page; http://Www.Firestationlive.net/