Comparing Memory Allocation Methods

Discussion in 'C++' started by Wei, May 7, 2004.

  1. Wei

    Wei Guest

    Wei, May 7, 2004
    #1
    1. Advertising

  2. "Wei" <> wrote in message
    news:...
    >

    http://msdn.microsoft.com/library/d.../base/comparing_memory_allocation_methods.asp
    >
    > On the above MSDN site, it says The malloc function has the
    > disadvantage of being run-time dependent. The new operator has the
    > disadvantage of being compiler dependent and language dependent.
    >
    > Can someone give examples to describe the disadvantage?


    Can anyone explain what the f**k MS are talking about?

    'language dependent' - I can only assume that means malloc is usable in C
    and C++ whereas new is only usable in C++.

    'compiler dependent' - perhaps that refers to the fact the VC++ 6 does not
    implement the new operator correctly. Something most other compilers manage
    to get right.

    'runtime dependent' - perhaps this refers to the C runtime library code that
    most VC++ programs link with. It's hardly a disadvantage, and it would apply
    to new as well.

    What is more the author of that page has completely ignored the fact that he
    is not comparing like with like. new adds very significant functionality
    that the other methods do not have (namely that it calls constructors and
    throws exceptions).

    I would just ignore this rubbish. In general C++ code you should use new,
    anything else is for specialised use only, when you know exactly why you
    need an alternative method of allocating memory.

    john
    John Harrison, May 7, 2004
    #2
    1. Advertising

  3. Wei

    Bill Seurer Guest

    Wei wrote:
    > http://msdn.microsoft.com/library/d.../base/comparing_memory_allocation_methods.asp
    >
    > On the above MSDN site, it says The malloc function has the
    > disadvantage of being run-time dependent. The new operator has the
    > disadvantage of being compiler dependent and language dependent.
    >
    > Can someone give examples to describe the disadvantage?


    If you use new or malloc your code might run somewhere other than on
    Windows. The author is trying to get you to use the Windows specific
    allocation functions. The disadvantage is to Microsoft, not you.
    Bill Seurer, May 7, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. s.subbarayan

    Dynamic memory allocation and memory leak...

    s.subbarayan, Mar 18, 2005, in forum: C Programming
    Replies:
    10
    Views:
    682
    Eric Sosman
    Mar 22, 2005
  2. Rodrigo Dominguez

    memory allocation and freeing memory

    Rodrigo Dominguez, Jun 13, 2005, in forum: C Programming
    Replies:
    11
    Views:
    586
    Jean-Claude Arbaut
    Jun 15, 2005
  3. Ken
    Replies:
    24
    Views:
    3,842
    Ben Bacarisse
    Nov 30, 2006
  4. chris
    Replies:
    6
    Views:
    974
    chris
    Oct 28, 2005
  5. Bjarke Hammersholt Roune
    Replies:
    14
    Views:
    1,171
    Bjarke Hammersholt Roune
    Mar 6, 2011
Loading...

Share This Page