Re: Can you write code directly in CIL ???

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Andreas Mueller" <me@xxxxxxxxxxx> wrote in message
news:41cjpeF1cm3s3U1@xxxxxxxxxxxxxxxxx
> Peter Olcott wrote:
>
>> "Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote
>> in message news:u3hVLnqCGHA.3064@xxxxxxxxxxxxxxxxxxxxxxx
>>
>>>Peter,
>>>
>>> I highly recommend that you read up on how Garbage Collection works
>>> exactly.
>>
>>
>> I already know this.
>
> No, you obviously don't. The problem is not that the GC will take any
> memory from your method, but that it is running in a separate thread. So
> lets say you method executes in 1/10 s. When garbage collection occurs, it
> will take way longer, simply because your method will halt in the middle
> of something and resume when the GC is done. So from inside your method,
> the execution time was still 1/10, but from the outside the execution time
> is way longer ( A little bit like theory of relativity :-) ).
>
> Relying on the GC to do or not to do something is a capital sin in .NET.
>
>> One thing that it can not do is to reclaim memory that is still in use.
> Correct, it will not try to get you memory, however it will stop you
> thread if it wants to
>> I remember reading the algorithm. It is some sort of aging system. In any
>> case even if my memory needs to be constantly checked to see if it is
>> still in use, I only need a single monolithic large block.
> Yea, and while t checks and sees that it is not allowed to touch you
> monolithic large block, you method will pause and take longer than 1/10s.
>> One thing that I do know about GC, is that it is ONLY invoked when memory
>> runs out, and is needed, otherwise it is never invoked.
> One thing that you must know when developing managed code, is that you
> *never* know when the GC is invoked.
> Watch your performance counters for garbage collection. You'll be
> surprised how busy the area :-)
>
> [snip]
>
> HTH,
> Andy
> --
> To email me directly, please remove the *NO*SPAM* parts below:
> *NO*SPAM*xmen40@*NO*SPAM*gmx.net

Andreas,

The only time the GC runs (un-forced) is when the creation of an object on
the GC heap would overrun the gen0 heap threshold. When this happens the GC
runs on the same thread as the object creator. That means that the GC won't
run as long as you don't create objects instances.
Note that this assumes there is no external memory pressure when there are
extra GC heap segments allocated, this would force the CLR to start a full
collection.

Willy.


.



Relevant Pages

  • Re: Can you write code directly in CIL ???
    ... >>> I highly recommend that you read up on how Garbage Collection works ... When garbage collection occurs, it will take way ... the execution time was ... >> One thing that it can not do is to reclaim memory that is still in use. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Alternatives to C: ObjectPascal, Eiffel, Ada or Modula-3?
    ... My problem with it is the lack of a garbage collection. ... pretty much have memory bugs, ... Modern GCs are much faster than older ones, ... Concurrent GCs exist, nevermind GCs that play fairly nicely with concurrent application code. ...
    (comp.programming)
  • Re: Can you write code directly in CIL ???
    ... but that it is running in a separate thread. ... When garbage collection occurs, it will take way longer, simply because your method will halt in the middle of something and resume when the GC is done. ... So from inside your method, the execution time was still 1/10, but from the outside the execution time is way longer (A little bit like theory of relativity ... In any case even if my memory needs to be constantly checked to see if it is still in use, I only need a single monolithic large block. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Heap and Memory Footprint
    ... memory associated), when the object is created memory is allocated in ... both the Java heap and the C native heap. ... hit a memory limit without a garbage collection occurring as only the ...
    (comp.lang.java.machine)
  • Re: Heap and Memory Footprint
    ... If you have any mixed language objects (i.e. Java objects which have underlying native memory associated), when the object is created memory is allocated in both the Java heap and the C native heap. ... It is important to explicitly call close- otherwise if the object gets promoted to the old area, the memory will not be freed until the object gets garbage collected from the old area which can take a very, very long time (and in the worst case you may have the process hit a memory limit without a garbage collection occurring as only the Java heap's behaviour will trigger garbage collection). ...
    (comp.lang.java.machine)