Tag Archives: refactoring

Analyzing events usage using a R# plugin

As you might already know, even if the .Net framework has a garbage collector, you can easily create memory leaks in your application.

The most common way to create a leak is to register to an event handler on a object that has a longer lifetime than the object where the handler is defined. The problem can also occurs by using static class such as EventManager (for more information see this blog post). Some .Net developers have been working on a way to go round the problem using Reflection, Weak Reference and other cool stuff. You can check out for example this excellent article on Code Project.

However, if you cannot change the way your declare events (because of internal policies in the company or because you don’t have the source code), you must be very carefull about the way you manage your events.

I’ve been working lately on a Resharper plugin that helps detecting events that are never unsubscribed. Basically, what is does is the following:

resharper_plugin

I’d like to have feedback from you .Net developpers, about whether you find such a plugin useful or not.

  • How do you deal with the event memory leak problem ?
  • Would you like to use my plugin ?
  • Would you like me to release it on a open source platform ?
  • What other kind of possible leaks are you thinking about to enhance the plugin ?

Please write a comment to let my know what you think. Thank you for your feedback !

The cost of building Visual Trees


Warning: count(): Parameter must be an array or an object that implements Countable in /homepages/5/d143877862/htdocs/japf/wp-content/plugins/wp-codebox/main.php on line 31

Fatal error: Uncaught Error: Call to undefined function eregi() in /homepages/5/d143877862/htdocs/japf/wp-content/plugins/wp-codebox/main.php:136 Stack trace: #0 /homepages/5/d143877862/htdocs/japf/wp-content/plugins/wp-codebox/main.php(75): wp_codebox_is_windowsie() #1 /homepages/5/d143877862/htdocs/japf/wp-content/plugins/wp-codebox/main.php(50): wp_codebox_highlight_geshi(Array) #2 [internal function]: wp_codebox_highlight(Array) #3 /homepages/5/d143877862/htdocs/japf/wp-content/plugins/wp-codebox/main.php(130): preg_replace_callback('/<p>\\s*623f1895...', 'wp_codebox_high...', '<p>In the curre...') #4 /homepages/5/d143877862/htdocs/japf/wp-includes/plugin.php(213): wp_codebox_after_filter('<p>In the curre...') #5 /homepages/5/d143877862/htdocs/japf/wp-includes/post-template.php(221): apply_filters('the_content', '<p>In the curre...') #6 /homepages/5/d143877862/htdocs/japf/wp-content/themes/twentythirteen/content.php(39): the_content('Continue readin...') #7 /homepages/5/d143877862/htdocs/japf/wp-includes/template.php( in /homepages/5/d143877862/htdocs/japf/wp-content/plugins/wp-codebox/main.php on line 136