473,387 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Comparing Memory Allocation Methods

Wei
http://msdn.microsoft.com/library/de...on_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?
Jul 22 '05 #1
2 1704

"Wei" <wa******@21cn.com> wrote in message
news:d3**************************@posting.google.c om...
http://msdn.microsoft.com/library/de...on_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
Jul 22 '05 #2
Wei wrote:
http://msdn.microsoft.com/library/de...on_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.
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: ira2402 | last post by:
Hi All, We are developing sw for a small embedded OS and we have limited memory. We are looking for algorithms, links, and articles about this. The goal is efficient utilization of small amount...
6
by: Michael Isaacs | last post by:
Regarding use of enum's, I am wondering what the cost of memory is when creating the enumeration on the calling side, and then using it on the function/method side. See example below. If I...
30
by: MAG1301 | last post by:
I've detected memory leaks in our huge .NET 1.1 C# application but couldn't localize them directly. So I've reduced the code to the following console application: using System; using System.IO;...
5
by: Le Minh | last post by:
Hi, i try to using unsafe programming to speed up my App. i dont know how to dynamic memory allocate. Anyone know it ? Thanks, Le Minh.
4
by: Tomassus | last post by:
Hi there, I have a problem with dynamic memory allocation. I know that it would have been easier to use vectors methods, but i want to know what i do here wrong. This is one of my methods in...
24
by: Ken | last post by:
In C programming, I want to know in what situations we should use static memory allocation instead of dynamic memory allocation. My understanding is that static memory allocation like using array...
1
by: Peterwkc | last post by:
Hello all expert, i have two program which make me desperate bu after i have noticed the forum, my future is become brightness back. By the way, my problem is like this i the first program was...
25
by: J Caesar | last post by:
In C you can compare two pointers, p<q, as long as they come from the same array or the same malloc()ated block. Otherwise you can't. What I'd like to do is write a function int comparable(void...
10
by: swornavidhya.mahadevan | last post by:
Which allocation (Static / Dynamic) is suitable for the situation when we are trying to allocate for a overloaded memory when the memory is full and no space to allocate. What will happen if both...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.