-
Junior Member
Memory allocation
What is the difference between C dynamic memory allocation, C++ dynamic memory allocation and Java memory allocation?
-
Expert Member
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
-
Junior Member
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.
-
Junior Member
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.
-
Junior Member
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.....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules