Wednesday, May 03, 2006

Jessica Fosler recently posted a great summary on common causes for .NET memory leaks ("You gotta learn to let it go: Top 4 memory leaks").  If you're leaking memory, I'd strongly suggest this as as starting point.

In my experience, static/shared events are the most likely culprit.  Anytime you're dealing with a static event, check and double-check to make sure you're unregistering your handlers during cleanup.  Here's what Jessica says about it:

Make sure you know who you're giving your object out to. If you're stuffing your object in a static (or shared) list, it should be removed at some point in time, as that shared list will hold open the lifetime of your object.

This also goes for hooking onto static events.  (I've mentioned this one before.)  The most common culprits are SystemEvents.UserPreferenceChanged and Application.Exit, Application.Idle etc.  If you're hooking onto these events, remember to unhook when you're ready for cleanup, otherwise the Application and/or SystemEvents class will keep your object alive.

Wednesday, May 03, 2006 5:00:15 PM (Central Daylight Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  | 
 Tuesday, April 25, 2006

Well, that didn't take long.  Yesterday, I posted a couple of annoyances about IE7, and today they released the full beta 2 - both issues are fixed.  One day turn-around?  I'm impressed :-P

Tuesday, April 25, 2006 6:11:55 PM (Central Daylight Time, UTC-05:00)  #    Disclaimer  |  Comments [2]  | 
 Monday, April 24, 2006

I'm liking IE7 a lot.  It is much improved over the previous version(s), but I've come across two annoyances that I have not seen reported in the forums.  Here are the repros:

Hang when Closing with Multiple Tabs from the Taskbar

  1. Verify that the "Do not warn me when closing multiple tabs" is unchecked (aside: "negative" options are confusing.  This should probably read "Warn me when closing multiple tabs" and should be checked by default)

     
     
  2. Open two or more tabs to any URL

     
     
  3. Minimize IE
  4. Close the instance of IE from the taskbar using the context menu


      
  5. IE will hang because the modal dialog that is asking to close all the tabs is not visible

 

The Disabled Back Button

Sometimes the back button does not enable when it should.

  1. Navigate to http://www.google.com
  2. Do a Google search (on "AJAX" for example)
  3. Though navigated to the search results, the back button is still disabled
  4. Go to the next page of search results - the back button is still disabled
Monday, April 24, 2006 11:49:00 PM (Central Daylight Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  | 
 Tuesday, April 18, 2006

Here is the link to everything I used in the talk - PowerPoint, *.express files, and source code: MUNG_RegEx Talk.zip (34.5 KB)

The RegexOptions.Compiled flag

Something I forgot to mention in the talk is the "RegexOptions.Compiled" flag.  If you are going to execute the exact same regular expression repeatedly, you can use this flag in addition to any other flags you may have specified (e.g. RegexOptions.IgnorePatternWhitespace).  This will cause the framework to dynamically compile the expression to IL instead of using RegEx op codes, and therefore dramatically increase performance. 

If you are dynamically creating regular expressions, do NOT use the "Compiled" flag.  Each unique compiled RegEx is kept in memory until the application quits - even if the RegEx object goes out of scope. 

Resources:

 

[Update] Fixed error in .express file

Tuesday, April 18, 2006 11:44:59 PM (Central Daylight Time, UTC-05:00)  #    Disclaimer  |  Comments [3]  | 
 Monday, April 17, 2006

I was listening to HanselMinutes over the weekend, and picked up a few windows tips that I thought I'd share (and to remind myself later if I forget):

  1. Alt-Tab while dragging - In most cases, people usually "set up" a drag by making sure windows are side-by-side, etc.  This isn't necessary.  Just start dragging and then Alt-Tab to the window you want to drag to.
     
  2. Right-click-drag - When dragging using the right mouse button, you get a context menu with several options at the end of the drag.

     
  3. Dragging to the taskbar - In addition to Alt-tabbing while dragging, you can bring a window to the front by dragging an item to its taskbar icon.  Then drop the item on the focused window, not the taskbar

     
Monday, April 17, 2006 4:36:12 PM (Central Daylight Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |