Archives

Archives / 2007
  • How to leak memory in .Net - Statics and Event Handlers

    For the past few days I’ve been investigating some memory leak issues in our desktop application. The problem started showing up when we saw that opening new documents and then closing them didn’t have any negative impact on the memory usage. Initial tests using vadump and process explorer confirmed that there was an issue and so we the developers started looking into it.

  • .Net framework hotfix wreaks havoc

    Last week all of us were baffled when suddenly one part of our application that uploads files to a FTP server stopped working. The strange thing was that the same build has been working without any issues for the past one week. We looked at everything that could have gone wrong, server, configuration, code but everything was setup fine and hadn't been changed. Also interestingly it stopped working for everyone except the developer who was responsible for the feature.

    The first thing we did was to enable detailed logging to see what was happening, the logs showed two problems

    1. We were incorrectly formatting the path of file to upload
    2. The .Net framework code was changing folders after login to the root folder of the ftp where it didn't have permissions to upload the file
    Further investigation showed that the second issue was not coming on the developer's machine. Most puzzling indeed.

    Then I remembered that last week .Net had issued a critical hotfix for .Net 2.0, could this be the issue. We verified that the developer didn't have the hotfix and all machines which were failing did have, Strike 1! Next we uninstalled the hotfix from one of the machines and the FTP uploads started working, Strike 2!! Finally we fixed the incorrect formatting of the ftp url and the issue got resolved on all machines with or without the hotfix, Strike 3! Issue resolved!

    The problem was that the hotfix changed the implementation of the FTP code inside the .Net framework so that it behaved differently when passed an incorrectly formatted url.

    This was the first time I saw a working app fail because of the way an incorrect argument was handled by a newer version of the framework. It was a good learning experience though :) Also this strengthens my belief in asserting all assumptions in code because if we had asserted that the url was infact of the format that we were expecting, this issue would never have happened in the first place.

  • Programmer's tools

    Here are some of the tools that I currently have installed on my dev machine. Most of them are freeware or have free versions available.

  • Make sure you know what you're fixing

    I’ve been working on this bug for the past one week, basically a call to the GDI+ APIs MeasureString and DrawString was failing with a very useful exception “A generic GDI+ error has occured” ;) , my initial hypotehesis was that the problem was coming because of the length of the string that we were trying to measure, at that time around 100000+ characters. In retrospect this now seems like such a foolish thing to hypotheize.

  • Is Ruby "The One"?

    I got back to application development using Java after spending the last 4 years developing applications using .Net and C++ and things have really changed!!! I have spent the last one month trying to catch up on all the new stuff in the Java world. Updating myself with the latest changes to the syntax only took one day though and I was surprised to see that in the latest incarnation Java 5 and .Net are like twins. If you don’t believe me then read this.

  • Notes on the software build process

    The build process is more than just a compilation of the code that is done on a developer's workstation, a good build process is able to generate the final set of artifacts that is sent to the user in one step. For e.g. a build process for a desktop application would build the installer, documentation, licenses etc. for the entire product, in case of a web application the build will compile the code files, supporting assets and deploy to a test or staging server. A good build system should be configurable and able to build multiple editions of the product.