Exception in application when profiling

I'm trying to profile an application but no matter what options I enable, it always throws an exception.

I can launch the debugger when the exception gets thrown and see why it is happening, but there is explanation for why it occurs.

My application is quite large, but the area it occurs in is small. The problem has arisen because a csv parser reads '3' in as 0.

This only happens in the profiler. It happens in debug and release. Changing the options seems to make it happen at different lines of the CSV file. I'm wondering if there is a strange interaction between garbage collection and profiling and something is being moved in memory while the profiler is doing something!

I'm running Windows 7 64 bit with 8gb RAM and a dual core processor. All the apps are .net 3.5


Nick Randell


  • Hi Nick,

    is your application using multiple threads?

  • No, it's a single threaded application.

    A string is read from the file. It is then passed to a method to create an object from that. The string is then passed to a csv parser for processing.

    When I read the string in the debugger after the exception is thrown, I see it starts with '3;'. However when I check the value read from the first entry, I see '0'. I've put in console diagnostics and they show the same problem.

    Changing various profiling options allows the program to run differing amounts!
    Nick Randell
  • We would need to see the program to have any idea what’s going on here.

    Anything where the exact timing of operations matters could possibly have its behaviour changed by the profiler, though.

  • I've got another example with this happening. Can you let me know where I can upload my application to so you can find it.

    With the small (ish) example I have, it behaves differently when I copy in the pdb for the main library I want to profile.

    This is on Windows 7, 64 bit using Performance Profiler 5.2 professional.
    Nick Randell
  • If the application isn't too large then you can send it to [email protected] and reference this post.

    If you hit any issues with the email then post again and i'll sort you out with an upload directory.


  • Hi Stephen.

    I tried emailing, but it looks like the attachment didn't get through. Can you sort out an upload directory please.


    Nick Randell
  • Hi Nick,

    could you send [email protected] an email about organizing an upload directory and reference this post that would be great. It will allow us to keep track of issues and offer you better support.


  • My results: with the same version I get different results. This is, in a way, only to be expected- profiling using the "Instrumentation" technique does change the behaviour of code in various ways. Luckily- we have been working on "Sampling" mode in our new major version which is in Alpha testing at the moment and with this (on Windows 7) I get pretty much identical results.

    Please try it (especially in Sampling mode):

    http://downloads.red-gate.com//EAP/ANTS ... .0.587.exe
  • I'm running into a similar issue with bizarrely random code execution - things like:
    returns 19, and then maybe a negative number if I run again.

    It works outside of the profiler.

    I'm going to try the v6 Beta....
  • Build 663 of the EAP is now out, and should hopefully address the issues on x64.

    justsml wrote:
    I'm running into a similar issue with bizarrely random code execution - things like:

    However, this is something I can't reproduce here even with older versions of the profiler. The bug that we found specifically affects methods that return floating point values on x64 systems.
    Andrew Hunter
    Software Developer
    Red Gate Software Ltd.
Sign In or Register to comment.