Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Dynamic memory allocation

Posted on 1998-09-23
9
Medium Priority
?
349 Views
Last Modified: 2013-12-03
Is there an advantage to use GlobalAllocate() and other Windows memory allocation functions as opposed to using C++'s "new" or C's malloc()? Does GlobalAllocate(), for example, work better with virtual memory? Note: I program in Win32 environment.

Thank you.
0
Comment
Question by:Zainal062797
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
9 Comments
 
LVL 1

Expert Comment

by:Bonev
ID: 1414750
The difference is that the C/C++ functions add an abstract layer that allows portability. By my opinion it is better to use them because they manage their own heap and it is easy to track down various memory problems like leaks and overwrites. In their implementation they use the Windows API functions for memory management adding a small overhead that reduces the speed a little bit, but certainly give you the advantage of better memory control.
0
 

Author Comment

by:Zainal062797
ID: 1414751
Thanks...
Where is the grading form?? It used to be at the end of the answer. But the last couple of times, I had to ask for it.

0
 
LVL 22

Expert Comment

by:nietod
ID: 1414752
It is best to use the C++ allocation procedures (except when some window-speciifc features are need, like the DDE share)  This will keep window's heap simpler (with less block and less gaps).  C++ will allocate a few large blocks out of window's heap and create its own heaps in these blocks.  If you allocate lots of objects, it is more efficient to allocate them in C++'s heaps rather than cluter up window's heap.  (It is more efficient, because your program is working in a smaller heap because it doesn't have to deal with blocks allocated from other programs and at the same time when windows needs to modify its heap, its heap is simpler because it has only the 1 or 2 heap objects from your program, rather than every block from your program.
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 22

Expert Comment

by:nietod
ID: 1414753
Bonev chose not to answer, so you don't have the option to grade.  Perhaps he will now?
0
 
LVL 1

Expert Comment

by:Bonev
ID: 1414754
I have posted that as a comment. In this way I give an opportunity to other experts to give their opinion. If you are happy with my comment I can post it as an answer. If not, you can wait for more comments in the discussion.

0
 
LVL 1

Accepted Solution

by:
Bonev earned 150 total points
ID: 1414755
As requested:

The difference is that the C/C++ functions add an abstract layer that allows portability. By my opinion it is better to use them because they manage their own heap and it is easy to track down various memory problems like leaks and overwrites. In their implementation they use the Windows API functions for memory management adding a small overhead that reduces the speed a little bit, but certainly give you the advantage of better memory control.

0
 
LVL 1

Expert Comment

by:Bonev
ID: 1414756
nietod, thanks
0
 

Author Comment

by:Zainal062797
ID: 1414757
Thanks...
Where is the grading form?? It used to be at the end of the answer. But the last couple of times, I had to ask for it.

0
 
LVL 1

Expert Comment

by:Bonev
ID: 1414758
It should be there.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question