Thread: What's so special about c#?

  1. #31
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    You can mark an object for collection and call GC.Collect();

    Besides whats the big deal about it possibly not being collected as soon as all references to a heap object are gone? If the program needed more memory for an allocation it would immediately collect everything that is safe to be collected. You probably can't manage it better yourself.

  2. #32
    Registered User
    Join Date
    Aug 2008
    Posts
    188
    Quote Originally Posted by valaris View Post
    You can mark an object for collection and call GC.Collect();

    Besides whats the big deal about it possibly not being collected as soon as all references to a heap object are gone? If the program needed more memory for an allocation it would immediately collect everything that is safe to be collected. You probably can't manage it better yourself.
    well, for 1, just because you mark an object for collection doesn't mean it will be collected, even with GC.Collect. objects get elevated to different generations depending on how long they live. GC.Collect is an all or nothing kinda deal, so if you want to free up memory for object a, which is generation 1, you need to free up *all* objects in generation 1, not to mention you have no idea what order objects are collected.

    also, true deterministic allocation/deallocation is important for applications where predictability is a requirement. many high-performance applications fall into this category.

  3. #33
    Registered User
    Join Date
    May 2007
    Posts
    147
    You probably can't manage it better yourself. (Memory management )
    I hear this a lot, and it simply isn't true.

    If it were even close to true, the wide range of C++ applications that manage rather large volumes of information (like SQL engines, 3D Studio Max, AutoCAD, FormZ, Pro-E, Catia, Photoshop) wouldn't work as well as they do.

    In fact, it is precisely because you CAN manage it better yourself that these ambitious applications aren't written in Java, C# or similar languages.

    I'll give you this, however - you can't manage it better with the same simplicity - that much is true.

    Also, the subject relative to deterministic destruction isn't as much about memory management specifically as it is about the RAII paradigm (or design pattern, if you think of it that way).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Printing a special type?
    By blernblan in forum C Programming
    Replies: 1
    Last Post: 06-02-2009, 03:35 PM
  2. locking actions to special threads
    By pheres in forum C++ Programming
    Replies: 2
    Last Post: 09-24-2008, 10:17 AM
  3. special characters removing from srting
    By cnu_sree in forum C Programming
    Replies: 5
    Last Post: 06-06-2007, 08:30 PM
  4. special function detection
    By zyd in forum C Programming
    Replies: 7
    Last Post: 02-28-2006, 03:25 PM
  5. Special (non) Keyboard Characters
    By TechWins in forum C++ Programming
    Replies: 3
    Last Post: 05-01-2002, 12:08 AM

Tags for this Thread