same assembly size for debug and release

T

Tony Johansson

Hello!

This program give the same size when building in debug and release.
How is that possible.???

using System;

public class UseGet
{
public int get
{
get
{
int get = 6;
return get;
}
}

private static void Main(string[] args)
{
int get = 10;
Console.WriteLine(get);
Console.WriteLine((new UseGet()).get);
}
}
 
T

Tony Johansson

Peter Duniho said:
At least two ways:

. The name of the build is not required to match the actual settings for
the build. Perhaps the two builds actually have the same settings.

. The primary optimizations that occur in a "Release" build are done by
the JIT compiler. The IL could actually be identical for both.

Also, make sure you are comparing the correct sizes. Depending on what
you're looking at, you may be seeing the "size on disk" which is rounded
up to the nearest sector size multiple.

Finally, don't rule out coincidence. Even if the builds are in fact
different in certain ways, that's no guarantee the files will be of
different lengths.

Pete

When I have the file compiled into debug and release I look at property for
the debug and release assembly and the size is identical saying 4,50 kB (4
608 byte).for both.

If I look at the IL code it's looks almost identical. Here is an example for
the main which is debug version
..method private hidebysig static void Main(string[] args) cil managed
{
.entrypoint
// Code size 28 (0x1c)
.maxstack 1
.locals init ([0] int32 get)
IL_0000: nop
IL_0001: ldc.i4.s 10
IL_0003: stloc.0
IL_0004: ldloc.0
IL_0005: call void [mscorlib]System.Console::WriteLine(int32)
IL_000a: nop
IL_000b: newobj instance void UseGet::.ctor()
IL_0010: call instance int32 UseGet::get_get()
IL_0015: call void [mscorlib]System.Console::WriteLine(int32)
IL_001a: nop
IL_001b: ret
} // end of method UseGet::Main

and here is main in release version
..method private hidebysig static void Main(string[] args) cil managed
{
.entrypoint
// Code size 25 (0x19)
.maxstack 1
.locals init ([0] int32 get)
IL_0000: ldc.i4.s 10
IL_0002: stloc.0
IL_0003: ldloc.0
IL_0004: call void [mscorlib]System.Console::WriteLine(int32)
IL_0009: newobj instance void UseGet::.ctor()
IL_000e: call instance int32 UseGet::get_get()
IL_0013: call void [mscorlib]System.Console::WriteLine(int32)
IL_0018: ret
} // end of method UseGet::Main

Now when I used C++ in the old days and compiled into debug and release the
difference was huge between these two.
So what I can't understand is these four questions.
1. How can the size be identical for debug and release ? I mean the debug
version should be greater because of the symbol table that must be used when
debugging the code so you can see what value different variable has.
2.How can the IL code be almost identical between these two ?
3. I mean when the size is the same and the IL code is almost the same why
should I use the release version in production?
4. Will the debug version have bad performance compared to release version.

I have google to find some answers to these questions but haven't find
anything sensible.

//Tony
 
J

Jason Keats

Tony said:
Now when I used C++ in the old days and compiled into debug and release the
difference was huge between these two.
So what I can't understand is these four questions.
1. How can the size be identical for debug and release ? I mean the debug
version should be greater because of the symbol table that must be used when
debugging the code so you can see what value different variable has.

Have you forgotten that the debug version also comes with an associated
..pdb file?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top