Women in Technology

Hear us Roar



Article:
  Modern Memory Management
Subject:   C++ has garbage collection?
Date:   2005-11-08 11:18:49
From:   orichy
Response to: C++ has garbage collection?

"I didn't know C++ had any more garbage collection than C had. You still need to new/delete memory or objects created on the heap just like malloc/free in C."


It's true that C++ has no garbage collection by default but it has RAII. And i think what the author wanted to say is that in C++ you rarely use new/delete, compared to malloc/free in C because C++ has a good standard library offering all containers one could ever need. :-)


BTW: The author never states, C++ had any gc as you seem to imply.


Regards

Full Threads Newest First

Showing messages 1 through 5 of 5.

  • C++ has garbage collection?
    2005-11-08 11:45:49  Lunchy [View]

    Good points, however, lumping C++ in with Perl and PHP and Java implies the language has GC built-in.

    It's not a big deal, but if I didn't know anything about C++, his statement would lead me to believe C++ has GC comparable to that found in Perl, Java, or PHP without the use of the STL or RAII techniques.
    • C++ has garbage collection?
      2005-11-08 11:51:13  orichy [View]

      I agree that the author should have stated this more clearly. On the other hand: Does PHP actually have GC?
      • C++ has garbage collection?
        2005-11-08 13:25:49  Lunchy [View]

        This is kinda funny. I honestly don't know anything about GC in PHP, but since it was used in conjunction with Perl and Java, I assumed it did, much like I would have done if I didn't know anything about C++! ;)

        Cheers!
        • C++ has garbage collection?
          2005-11-09 06:07:51  orichy [View]

          Hehe, well, it seems that PHP does indeed have GC, using reference counting. But i wouldn't call it true GC because it's not much different from using shared_ptr in C++, and it has the same problem with cyclic references:

          http://www.hudzilla.org/php/18_1_11.php
          http://phplens.com/phpeverywhere/?q=node/view/131

          BTW: Even though i wouldn't use it, i would like C++ to get GC because that would mean more C++ programmers. :-)

          Regards!
          • C++ has garbage collection?
            2006-01-14 18:02:49  evanh [View]

            I'm of the opinion that C++'s memory and speed problems stem mainly from it's terrible standard libraries. Same goes for Java. I can't speak for the other languages having never used a desktop app written with one of them to compare with C.


            Evan