Results 1 to 5 of 5

Thread: Memory allocation

  1. #1
    Junior Member
    Join Date
    Feb 2007
    Answers
    7

    Memory allocation

    What is the difference between C dynamic memory allocation, C++ dynamic memory allocation and Java memory allocation?


  2. #2
    Expert Member
    Join Date
    Apr 2008
    Answers
    1,859

    Re: Memory allocation

    hi friends

    Operators new and delete are exclusive of C++. They are not available in the C language. But using pure C language, dynamic memory can also be used through the functions malloc, calloc, realloc and free, defined in C++ in the <cstdlib> header file, and since C++ is a superset of C, these functions are also available to C++ programmers

    The memory blocks allocated by these functions are not necessarily compatible with those returned by new, so each one should be manipulated with its own set of functions or operators.

    C :Use "malloc", "calloc" and "free":
    C++:Use "new" and "delete":

    hope this will be useful

    Thanks
    Deepasree


  3. #3
    Junior Member
    Join Date
    Aug 2008
    Answers
    15

    Re: Memory allocation

    Hi,
    In c, memory allocated by calling methods such as malloc(), calloc(), and realloc().. deallocation is occured by free().
    In c++, memory allocated by new Operator. deallocation is occured by delete().
    In java, memory allocated by new Operator. deallocation is occured automatically.


  4. #4
    Junior Member
    Join Date
    Sep 2008
    Answers
    2

    Re: Memory allocation

    hi viewers,
    In c++for memory allocation we are using new,delete
    for memory allocation we are using new,
    for memory deallocation delete keyword is used
    but in c we are using malloc,calloc,realloc,free.
    the purpose of malloc is allocating memory,
    realloc is used for reallocating ,
    calloc is used for adding new memory ,
    for deleteing we are using free function.the major diffrence is in c++ the new operator do the all operations like malloc,calooc,dealloc........................................

    Last edited by sateeshmca07; 09-14-2008 at 10:34 AM.

  5. #5
    Junior Member
    Join Date
    Oct 2008
    Answers
    4

    Re: Memory allocation

    Also adding to the above...
    In c++ for dynamic memory allocation we use new and delete operator...
    we can customize (overload these operators) to meet our goals....
    i think in c we can not do this ....
    correct if i m wrong.....


  6.  Sponsored Ads
    Ad


     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact