You probably already have done this, but you should make sure that there is no problem in your build script and that you made a complete rebuild of the executable. If the problem doesn't go away, my first suspicion would be that your code is buggy and for whatever reason you only notice it when optimizations are switched on and debugging info is off.

You should definitely try to pinpoint the bug in the optimized build. Even without debugging info you might be able to find out what goes wrong by running the program in the debugger (switch off Tools->Options->Debugging->"Enable just my code" in Visual Studio and, if necessary to trigger the bug, "Suppress JIT optimization on module load" too). Selectively commenting out code and introducing some kind of logging may also help to locate the problem, of course.

Best regards,
Stephan

By on 3/30/2008 2:02 PM ()

Thanks, Stephan, for your comment. Those heisenbugs are really tricky to debug.
With the help of Don Syme and Kean Walmsley, I was able to track it down.
It was some life management issue: I wasn't disposing of some IDisposable objects, and, so, with the optimizations affecting the gargage collection, the bug would appear or disappear.

By on 3/30/2008 2:26 PM ()

So does the F# compiler indeed apply different optimizations depending on whether the "-g" flag is given on the command line (without changing the "-O" optimization level)? I wouldn't expect that.

By on 3/30/2008 11:19 PM ()

So does the F# compiler indeed apply different optimizations depending on whether the "-g" flag is given on the command line (without changing the "-O" optimization level)? I wouldn't expect that.

The help output for fsc.exe says this for -g:

-g: Produce debug file. Disables optimizations if a -O flag is not given.

So it seems that -Ooff is the default when using -g

By on 4/1/2008 10:30 AM ()

Sure, but in a release build I use -g together with -O2 or -O3, of course.

By on 4/1/2008 10:59 AM ()

I don't think it does, but I guess the -g flag does somehow change the exact garbage collection process.

By on 3/30/2008 11:25 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper