you explain me but still i am in confusion of unmanged code and data.
In a previous post you mention the statement "The clr will sometimes
move your data behind
the scenes"
Please explain Further the above statement.
One More thing sir, can you Please define unmanaged code and data in
the similar way as you define manged code and data.
Thank You
With regards
Tarun Sinha
> you explain me but still i am in confusion of unmanged code and data.
> In a previous post you mention the statement "The clr will sometimes
> move your data behind the scenes"
> Please explain Further the above statement.
It's called compacting garbage collection. At unpredictable times,
the clr will pause the execution of managed code and defragment
memory by moving managed objects. Generally, you don't need
to care about this unless you use pointers with managed objects.
If you really need pointers into managed objects, you need to pin
the objects. But don't unless you really have to.
> One More thing sir, can you Please define unmanaged code
> and data in the similar way as you define manged code and
> data.
"Unmanaged" simply means, it's not controlled or defined by
the clr. A discussion of unmanaged code and data is really
outside the scope of this newsgroup.
Tasos Vogiatzoglou - 16 May 2006 14:38 GMT
The "usual" (unmanaged code) is produced by a compiler and it is
immediatelly available to the CPU for running. This means that a
program in unmanaged code is essentially a group of CPU instructions.
Managed code is a "intermediate" state of code where you need an
additional layer (virtual machine) in order to translate managed code
to pure CPU instructions (that the CPU can understand).
Garbage collection is not something particular to managed code. Managed
code has to do with the need of an intermediate layer in order to
execute it. This "intermediate layer" usually provides additional
services like memory reclaiming mechanism, just in time compilers etc
etc
Pointer can be used in both managed/unmanaged code. The only difference
is that the CLR (the .NET virtual machine) forces you to do this in an
unsafe context. By saying unsafe that means that the pointer can show
anywhere you like (and potentialy do something wrong). There is the
IntPtr class in .net where you can use pointers outside of an unsafe
context although in a limited fashion.
Best regards,
Tasos