Coffeehouse Post

Single Post Permalink

View Thread: "Near C Performance" w/ TraceMonkey JavaScript Engine
  • User profile image
    Cannot​Resolve​Symbol

    kasajian said:
    Sven Groot said:
    *snip*

    I don't think that's what he said.  Only talking about object construction.  In allocating dynamic memory in C# is faster than allocating in C.  The reason is because C# has garbage collection and thus can have a much simpler allocator.   In some cases, the allocation is simply a pointer-increment, which is similar to the speed of alloating an object on the stack.   In C and C++, some kind of a heap is used, so it's more expensive.   But this comparison rather naive.  C# than incurs a cost when the garbage collector runs, which C and C++ would not have.   However, the speed improevement of dynamic memory allocation with GC helps offset the cost of having a GC in the first place.

     

    In most real-world cases, this stuff doesn't matter.  A few places it does.  For instance, the fact that the time that the GC can take to collect is non-deterministic, it could be a problem in some cases when developing for real time systems.   But I wouldn't say categorically that GC can't be used (plenty of real time systems that use GC).  It all depends on what you're trying to do.

    Why are you arguing over a two-year-old thread?