Archive for June, 2004

C# Express: Getting Started

Tuesday, June 29th, 2004

C# Express: Getting Started

You’ve downloaded and installed C# Express and played with some menu options. Now what? We’ve tried to make it look friendly, but heck, it can still be intimidating if you’ve not used Visual Studio before. Here are some suggestions as to how to get started with C# Express.


 



  1. New to C# and Windows programming?

    If C# Express is going to be the first development system you have used for writing Windows application, well congratulations – you made a great choice. Seriously, C# Express is great for learning how to program, and making some great-looking Windows applications at the same time. Your programs will look like real Windows programs. Why? Because they ARE real Windows programs.

    In order to get going, I would recommend you look at the online help topics entitled How to: Create a Console Application with C# Express and How to: Create a Window Application with C# Express. You can find these articles in the C# Express Help, or on the web here and here.

    Work through the step-by-step guides, and you’ll end up creating two new projects and will learn a lot about using the Visual Studio code authoring environment along the way. Then take a while to read the Getting Started with Visual C# Express and C# Language Primer sections.


 



  1. New to C#, but with previous Windows programming experience?

    If C# Express isn’t your first programming environment, perhaps you’re a Visual Basic or Visual C++ programmer, you’ll want to get up to speed with the C# language. You can probably skim-read the C# Language Primer section, and go straight to the C# Reference section for the heavy-duty reference. You might also want to read the latest C# Language Spec.


  2. Plenty of programming experience, but new to Visual Studio?

    If you are trying out C# Express as a way to get an idea as to how Visual Studio works, I’d recommend you work through those How To: articles, and also check out the topic Using Visual C# Express. This will give you a quick introduction to how things work, and also give you some tips about entering your code faster.

There are many, many C# resources and web sites on the Internet and you’ll find that almost all the sample code you can find will work perfectly. If you have any favourite resources, feel free to add them as comments to this posting.


[via Microsoft WebBlogs]

FreeBSD Ports: When Things Go Wrong

Tuesday, June 29th, 2004

FreeBSD Ports: When Things Go Wrong (Posted 28 Jun 2004 by Ray)

[via Librenix.com | Linux Sysadmin Central]

Is this Project Worthwhile?

Tuesday, June 29th, 2004

Is this Project Worthwhile?

Not all projects should be done. Some projects don’t even rate discussion. But sometimes it’s a lot harder to tell when a project is worthy and should be considered. Here are some questions I ask when trying to evaluate when a project is worthwhile:



  • What business need does this project fill? (Does the organization obtain value from this business need)
  • Is this project a strategic project for us? What makes it strategic? (Does the strategic reason behind the project change the importance of the project?)
  • How does this project fit into all the projects we’d like to do? (Does this project make sense for us to do?)
  • Have we done a project like this before? Were we successful? What did it take for us to be successful? Do we have any doubts about our ability to do this project? What are those doubts? (Are we doomed before we start?)
  • Do we have the staff or other resources to do the project? (If we can’t adequately fund the project, what should we do differently?)
  • What is the effect of finishing this project on time, not finishing this project on time, or not finishing the project at all? What ripple effect does this project have on others?

I supposed if I wanted to make this easier, I could have arranged everything in a table with a yes or no at the top of each column, and you could just mark yes or no. If you have enough yes’s, the project is worthwhile. The problem I have with that approach is that when I ask the first couple of questions with a senior management team, the answers aren’t always yes or no. Sometimes the business need is clear. Sometimes the strategic importance of the project is to have a small project to practice a new set of techniques on. Sometimes the time constraints make the business need clear.


If you use other questions, I hope you post them in a comment. Knowing whether a project is worthwhile is a huge part of management’s necessary decision-making. Because if a project is worthwhile, it’s worth funding, staffing, and moving along. If it’s not worthwhile, it’s worth killing — quickly.


[via Managing Product Development]

gLabels: Ready for prime time

Monday, June 28th, 2004

gLabels: Ready for prime time

[via NewsForge]

The Sound of Your Firewall

Sunday, June 27th, 2004

The Sound of Your Firewall

Using Jabber as a Log Monitor

Thursday, June 10th, 2004

Using Jabber as a Log Monitor (Posted 10 Jun 2004 by Ray)

[via Librenix.com | Linux Sysadmin Central]

How to Make Your Web Site Work with Windows XP Service Pack 2

Thursday, June 3rd, 2004

How to Make Your Web Site Work with Windows XP Service Pack 2


If you:





  • manage a website


  • manage a company to manage / develop your website for you


  • are involved in building, coding, design, QAing, PMing, architecting, anythinging <?> websites


  • write, maintain website id / UI guidelines & code


  • are responsible for accessibility & usability of websites

Then:


 


Make sure you have reviewed this article ‘How to Make Your Web Site Work with Windows XP Service Pack 2’ and plan accordingly.




  • If you know anyone in the webdev & online marketing industry, pass the link on.



  • If you want to know the ‘what’ and ‘why’ (non-technical) of Windows XP SP2 go here.

Thanks to Kent Sharkey for the reminder!


posted on Saturday, May 29, 2004 11:45 AM


[via Alex Barnett]

GC Performance Counters

Thursday, June 3rd, 2004

GC Performance Counters

There are many .NET Memory Performance Counters and this is meant to give you some guidelines in interpreting the counter data and how to correlate them. This assumes you have a basic understanding of GC.


 


First thing you may want to look at is “% Time in GC”. This is the percentage of the time spend in GC since the end of the last GC. For example, it’s been 1 million cycles last GC ended and we spent 0.3 million cycles in the current GC, this counter will show 30%.


 


What is a health value for this counter? It’s hard to say. It depends on what your app does. But if you are seeing a really high value (like 50% or more) then it’s a reasonable time to look at what’s going on inside of the managed heap. If this number is 10%, it’s probably better to look elsewhere in your app because even if you could get rid of half of that, you would only be saving 5% - most likely not very worthwhile.


 


If you think you are spending too much time in GC, it’s a good time to look at “Allocated Bytes/sec” which shows you the allocation rate. This counter is not exactly accurate when the allocation rate is too low – meaning that if the sampling frequency is higher than the GC frequency as the counter is only updated at the beginning of each GC.


 


When each GC begins, there could be 2 cases:


 


1)      Gen0 is basically full (meaning that it wasn’t large enough to satisfy the last small object allocation request);


2)      The LOH (Large Object Heap) is basically full (meaning that it wasn’t large enough to satisfy the last large object allocation request); 


 


When the allocation request can’t be satisfied, it triggers a GC. So when this GC begins we update the value this counter uses by adding the number of allocated bytes in gen0 and LOH to it, and since it’s a rate counter the actual number you see is the difference between the last 2 values divided by the time interval.


Let’s say you are sampling every second (which is the default in PerfMon) and during the 1st second a Gen0 GC occured which allocated 250k. So at the end of the 1st second PerfMon samples the counter value which will be (250k-0k) / 1 second = 250k/sec. Then no GCs happened during the 2nd and the 3rd second so we don’t change the value we recorded which will still be 250k, now you get (250k-250k) / 1 second = 0k/sec. Then let’s say a Gen0 GC happened during the 4th second and we recorded that we allocated 505k total, so at the end of the 4th second, PerfMon will show you (505k-250k) / 1 second = 255k/sec.


This means when GC doesn’t happen very frequently, you get these 0k/sec counter values. But if say there’s always at least one GC happening during each second, you will see an accurate value for the allocation rate (when you are sampling every second, that is).


We also have a counter that’s just for large objects – “Large Object Heap size”. This is updated at the same time “Allocated Bytes/sec” is updated and it just counts the bytes allocated in LOH. If you suspect that you are allocating a lot of large objects (in Whidbey this means 85000 bytes or more), you can look at this counter along with “Allocated Bytes/sec” to verify it.


 


Allocating at a high rate definitely is a key factor that causes GC to do a lot of work. But if your objects usually die young, ie, mostly Gen0 GCs, you shouldn’t observe a high percentage of time spend in GC. Ideally if they all die in Gen0 then you could be doing a lot of Gen0 GCs but not much time will be spent in GC as Gen0 GCs take little time.


 


Gen2 GC requires a full collection (Gen0, Gen1, Gen2 and LOH! Large objects are GC’ed at every Gen2 GC even when the GC was not triggered by lack of space in LOH. Note that there isn’t a GC that only collects large objects.) which takes much longer than younger generation collections. A healthy ratio is for every 10 Gen0 GC we do a Gen1 GC; and for every 10 Gen1 GC we do a Gen2 GC. If you are seeing a lot of time spent in GC it could be that you are doing Gen2 GC’s too often. So look at collection counters:


 


“# Gen 0 Collections”


“# Gen 1 Collections”


“# Gen 2 Collections”


 


They show the number of collections for the respective generation since the process started. Note that a Gen1 collection collects both Gen0 and Gen1 in one pass – we don’t do a Gen0 GC, and then determine that no space is available in Gen0, then we go do a Gen1 GC. Which generation to collect is decided at the beginning of each GC.


 


If you are seeing a lot of Gen2 GCs, it means you have many objects that live for too long but not long enough for them to always stay in Gen2. When you are spending a lot of time in GC but the allocation rate is not very high, it might very well be the case that many of the objects you allocated survived garbage collection, ie, they get promoted to the next generation. Looking at the promotion counters should give you some idea, especially the Gen1 counter:


 


“Promoted Memory from Gen 0”


“Promoted Memory from Gen 1”


 


Note that these values don’t include the objects promoted due to finalization for which we have this counter:


 


“Promoted Finalization-Memory from Gen 0”


 


It gets updated at the end of each GC. Note that in Everett there’s also the “Promoted Finalization-Memory from Gen 1”counter which was removed in Whidbey. The reason was it was not useful. The “Promoted Finalization-Memory from Gen 0” counter already has the memory promoted from both Gen 0 and Gen 1. We should really rename it to just “Promoted Finalization-Memory”.


 


One of the worst situations is when you have objects that live long enough to be promoted to Gen2 then die quickly in Gen2 (the “midlife crisis” scenario). When you have this situation you will see high values for “Promoted Memory from Gen 1” and lots of Gen2 GCs. You can then use the CLRProfiler to find out which objects they are.


 


Note that when a finalizable object survives all the objects it refers to also survive. And the values for “Promoted Finalization-Memory from Gen X” include these objects too. Using the CLRProfiler is also a convenient way to find out which objects got finalized.


 


When you observe high values for these promotion counters, you will most likely observe high values for the Gen1 and Gen2 heap sizes as well. These sizes are indicated by these counters:


 


“Gen 1 heap size”


“Gen 2 heap size”


 


We also have a counter for Gen 0 heap size but it means the budget we allocated for the next GC (ie, the number of bytes that would trigger the next GC) and not the actual Gen 0 size which is either 0 or a small number if there’s pinning in Gen 0.


 


The heap size counters are updated at the end of each GC and indicate values for that GC. Gen0 and Gen1 heap sizes are usually fairly small (from ~256k to a few MBs) but Gen2 can get arbitrarily big.


 


If you want to get an idea of how much memory allocated total on the GC heap, you can look at these 2 counters:


 


“# Total committed Bytes”


“# Total reserved Bytes”


 


They are updated at the end of each GC and indicate the total committed/reserved memory on the GC heap at that time. The value of the total committed bytes is a bit bigger than


 


“Gen 0 heap size” + “Gen 1 heap size” + “Gen 2 heap size” + “Large Object Heap Size”


 


When we allocate a new heap segment, the memory is reserved for that segment and will only be committed when needed at an appropriate granularity. So the total reserved bytes could be quite a bit bigger than the total committed bytes.


 


If you see a high value for “# Induced GC” it’s usually a bad sign – someone is calling GC.Collect too often. It’s often a bug in the app when this happens.