views:

114

answers:

3

I recently wrote an implementation of the Canonical Huffman compression algorithm. I have a 500kb test file that can be compressed to about 250kb when running the debug and release builds from within Visual Studio 2008. However when I run the release build straight from the executeable the test file only compresses to about 330kb.

I am assuming that something is going wrong when the file is written using fwrite(). I have tested the program and confirmed that uncompressing the files always produces the correct uncompressed file.

Does anyone know why this could possibly be? How could the same executeable file be producing different sized outputs based on where it is launched from?

+3  A: 

Sounds like an uninitialized value somewhere. See also: http://stackoverflow.com/questions/907812/program-crashes-when-run-outside-ide

Running in IDE will initialize values to global defaults, running outside IDE doesn't, so any uninit'd variables will have different values.

Justicle
+2  A: 

Check out the the /RTCu compiler option to help detect use of uninitialized variables.

Stephen Nutt
Thanks, I tried using that compiler flag but I didn't receive any new information regarding uninitialised variables.
waffleShirt
A: 

Try running it through App Verifier and see what it finds.

Alex
Thanks so much, I quickly ran the AppVerifier and I am getting an access violation somewhere. So that gives me a starting point.
waffleShirt
Turns out there was an array out of bounds read happening, surprised is wasn't caught by the debugger.
waffleShirt