Business Das perfekte Beratungsgespräch: Tipps und Tricks Sabine Henschel4. Juli 2024 Business Mindset Coach: Ihr Schlüssel zu einem neuen Denken Sabine Henschel4. Juli 2024 Familie Kollegiale Beratung in der Pflege: Zusammen stark Sabine Henschel3. Juli 2024 Familie Was kostet eine Beratung beim Notar wegen Erbrecht: Ein Ratgeber Sabine Henschel2. Juli 2024 Business Was kostet eine
Regardless of how they come to be (Reflection.Emi t, etc), dynamic
assemblies are treated the same as regular assemblies; there is no
good way to unload an assembly from an active appdomain. You can,
however, load it into a second app-domain and then kill the app-
domain. A good bet is to (for instance) use a static cache so that you
don't end up creating the same code over and over, but simply re-use
the assembly you emitted earlier.
Executing code is treated as normal; instances will be collected (or
not) using the same rules.
On Thu, 04 Oct 2007 06:04:01 +0100, Jon Harrop wrote:
If you do metaprogramming in C#, is the generated code garbage collected
or does it leak indefinitely?
Without providing more detail, I find it difficult to be sure what you're
really trying to do.
If you dynamically create and load assemblies, you should probably load
them into a new appdomain. You cannot unload an assembly, but you can
discard an appdomain and discarding the appdomain will discard all the
assemblies loaded into it with it.
I think he's trying to prove that F# is superior to C#. That's Jon
Harrop's usual purpose on this group ;)
Interstingly, I think it is a valid discussion - but the important
context is: "at what?". Functional languages do have advantages,
especially in areas such as science / modelling - however, it isn't
necessarily a great fit for the typical business application.
It is *certainly* a much more meaningful discussion than the far-too-
regular VB vs C# ;-p
On Oct 4, 10:29 am, Marc Gravell <marc.grav...@g mail.comwrote:
I think he's trying to prove that F# is superior to C#. That's Jon
Harrop's usual purpose on this group ;)
>
Interstingly, I think it is a valid discussion - but the important
context is: "at what?". Functional languages do have advantages,
especially in areas such as science / modelling - however, it isn't
necessarily a great fit for the typical business application.
Absolutely.
It is *certainly* a much more meaningful discussion than the far-too-
regular VB vs C# ;-p
True. I just wish Jon would get into it properly rather than just
asking leading questions: "If you do X does C# behave badly", "Is C#
going to give way to F#" etc.
"Jon Skeet [C# MVP]" <skeet@pobox.co mha scritto nel messaggio
news:1191491052 .847982.175010@ k79g2000hse.goo glegroups.com.. .
On Oct 4, 10:29 am, Marc Gravell <marc.grav...@g mail.comwrote:
I think he's trying to prove that F# is superior to C#. That's Jon
Harrop's usual purpose on this group ;)
>>
>Interstingly , I think it is a valid discussion - but the important
>context is: "at what?". Functional languages do have advantages,
>especially in areas such as science / modelling - however, it isn't
>necessarily a great fit for the typical business application.
>
Absolutely.
>
>It is *certainly* a much more meaningful discussion than the far-too-
>regular VB vs C# ;-p
>
True. I just wish Jon would get into it properly rather than just
asking leading questions: "If you do X does C# behave badly", "Is C#
going to give way to F#" etc.
>
Jon
>
Agree. In this way he's actually doing more harm than good for F# community.
There are better ways to evangelize new ideas.
True. I just wish Jon would get into it properly rather than just
asking leading questions: "If you do X does C# behave badly", "Is C#
going to give way to F#" etc.
You forget that he thinks ML is more used than C#.
On Thu, 04 Oct 2007 06:04:01 +0100, Jon Harrop wrote:
>If you do metaprogramming in C#, is the generated code garbage collected
>or does it leak indefinitely?
>
Without providing more detail, I find it difficult to be sure what you're
really trying to do.
>
If you dynamically create and load assemblies, you should probably load
them into a new appdomain. You cannot unload an assembly, but you can
discard an appdomain and discarding the appdomain will discard all the
assemblies loaded into it with it.
Right. I think I'm getting to grips with this. So you must deallocate code
explicitly yourself, i.e. it is not garbage collected. To be able to
deallocate code there is the technical issue of wrapping your assembly in
an appdomain.
I read somewhere that types cannot be collected but that makes sense because
(I believe) the .NET platform prohibits structural subtyping. So all types
are regarded as different even if they are structurally identical, e.g. if
you define an (int, float) pair in two different assemblies then they are
considered to be different types. So types have the same place as code
in .NET from the point of view of allocation, and deallocating an appdomain
will deallocate the types it defines.
One final question: is code deallocation safe? So, if function A in assembly
A' calls function B in assembly B' and you deallocate the appdomain
containing B' before calling A, do you get a nice exception or a nasty
access violation?
Business Das perfekte Beratungsgespräch: Tipps und Tricks Sabine Henschel4. Juli 2024 Business Mindset Coach: Ihr Schlüssel zu einem neuen Denken Sabine Henschel4. Juli 2024 Familie Kollegiale Beratung in der Pflege: Zusammen stark Sabine Henschel3. Juli 2024 Familie Was kostet eine Beratung beim Notar wegen Erbrecht: Ein Ratgeber Sabine Henschel2. Juli 2024 Business Was kostet eine
On Oct 4, 11:47 pm, Jon Harrop <j...@ffconsult ancy.comwrote:
<snip>
One final question: is code deallocation safe? So, if function A in assembly
A' calls function B in assembly B' and you deallocate the appdomain
containing B' before calling A, do you get a nice exception or a nasty
access violation?
On Oct 4, 11:47 pm, Jon Harrop <j...@ffconsult ancy.comwrote:
>One final question: is code deallocation safe? So, if function A in
>assembly A' calls function B in assembly B' and you deallocate the
>appdomain containing B' before calling A, do you get a nice exception or
>a nasty access violation?
>
You'll get an AppDomainUnload Exception.
Ok.
Can you garbage collect generated code by putting it in an app domain and
wrapping the app domain in a class that uses a finalizer to explicitly
deallocate the app domain?
Business Das perfekte Beratungsgespräch: Tipps und Tricks Sabine Henschel4. Juli 2024 Business Mindset Coach: Ihr Schlüssel zu einem neuen Denken Sabine Henschel4. Juli 2024 Familie Kollegiale Beratung in der Pflege: Zusammen stark Sabine Henschel3. Juli 2024 Familie Was kostet eine Beratung beim Notar wegen Erbrecht: Ein Ratgeber Sabine Henschel2. Juli 2024 Business Was kostet eine
>
Ok.
>
Can you garbage collect generated code by putting it in an app domain and
wrapping the app domain in a class that uses a finalizer to explicitly
deallocate the app domain?
Comment