Click here to Skip to main content
15,907,326 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: copy a registry value to another value Pin
pubis16-Jun-10 4:26
pubis16-Jun-10 4:26 
GeneralRe: copy a registry value to another value Pin
«_Superman_»16-Jun-10 18:50
professional«_Superman_»16-Jun-10 18:50 
GeneralRe: copy a registry value to another value Pin
pubis17-Jun-10 4:00
pubis17-Jun-10 4:00 
AnswerRe: copy a registry value to another value Pin
pubis16-Jun-10 7:58
pubis16-Jun-10 7:58 
QuestionLarge Object Creation Pin
Baltoro15-Jun-10 13:06
Baltoro15-Jun-10 13:06 
AnswerRe: Large Object Creation Pin
Stephen Hewitt15-Jun-10 14:05
Stephen Hewitt15-Jun-10 14:05 
AnswerRe: Large Object Creation Pin
T210215-Jun-10 21:36
T210215-Jun-10 21:36 
AnswerRe: Large Object Creation Pin
Aescleal16-Jun-10 6:35
Aescleal16-Jun-10 6:35 
It depends on your compilers runtime library but generally the operating system doesn't have a lot to do with the C++ heap. As a first approximation what happens for newing objects is that the runtime allocates a big chunk of memory and then suballocates objects out of that block. When it runs out of that block it allocates another and starts allocating out of that.

However the real world of C++ allocators and operating system heaps is rarely that simple anymore. For example Windows 2000 (I think, haven't got my reference books to check so I could well be wrong) introduced a small object heap that allocated chunks of memory for objects of different size ranges to avoid fragmentation of the heap. At least one C++ compiler I've used used a similar set of blocks for different sizes for the same reasons.

Other optimisations I've seen include different heaps or blocks per thread. Most programmers don't want their threads blocking if a memory allocation is attempted and then there's the whole issue of using garbage collection for recovering memory for the heap rather than doing it when the program deletes an object. If you defer memory recovery to a garbage collector you end up avoiding one of the bottle necks in multithreaded code if the heap is shared between threads.

So basically only worry about it if you find that you can't create the objects you need or if you've profiled your app and found that it's spending way too much time in the memory allocator.

Cheers,

Ash

PS: There's no such thing as "class objects" in C++. Classes are just things the compiler sees, once the program is compiled classes don't really exist anymore, unlike Java or Smalltalk where everything's an object including classes.
AnswerThanks for Information Pin
Baltoro16-Jun-10 13:53
Baltoro16-Jun-10 13:53 
QuestionMSMQ Events in 64 Bit Windows 2003 Server Pin
Hariharan.T15-Jun-10 11:13
Hariharan.T15-Jun-10 11:13 
QuestionDrawing a polygon onto a DIB? Pin
Kiran Satish15-Jun-10 6:47
Kiran Satish15-Jun-10 6:47 
AnswerRe: Drawing a polygon onto a DIB? PinPopular
CPallini15-Jun-10 7:15
mveCPallini15-Jun-10 7:15 
Questionplotting in vc++ [modified] Pin
b-rad31115-Jun-10 5:03
b-rad31115-Jun-10 5:03 
AnswerRe: plotting in vc++ Pin
Maximilien15-Jun-10 6:40
Maximilien15-Jun-10 6:40 
GeneralRe: plotting in vc++ Pin
b-rad31115-Jun-10 7:12
b-rad31115-Jun-10 7:12 
Questionsynchronization of variables Pin
Sakhalean15-Jun-10 3:08
Sakhalean15-Jun-10 3:08 
AnswerRe: synchronization of variables Pin
Cedric Moonen15-Jun-10 3:14
Cedric Moonen15-Jun-10 3:14 
GeneralRe: synchronization of variables Pin
Joe Woodbury15-Jun-10 6:15
professionalJoe Woodbury15-Jun-10 6:15 
GeneralRe: synchronization of variables Pin
Aescleal15-Jun-10 8:58
Aescleal15-Jun-10 8:58 
AnswerRe: synchronization of variables Pin
Maximilien15-Jun-10 3:24
Maximilien15-Jun-10 3:24 
GeneralRe: synchronization of variables Pin
Niklas L15-Jun-10 3:32
Niklas L15-Jun-10 3:32 
AnswerRe: synchronization of variables Pin
Joe Woodbury15-Jun-10 6:17
professionalJoe Woodbury15-Jun-10 6:17 
Question"the attempt to edit the code in cimageDoc::OnSegManual in file--- failed" in MFC classWizard Pin
jianzhuhuai14-Jun-10 23:03
jianzhuhuai14-Jun-10 23:03 
QuestionTemplate and preprocessor macros Pin
rrrado14-Jun-10 22:35
rrrado14-Jun-10 22:35 
AnswerRe: Template and preprocessor macros Pin
Code-o-mat15-Jun-10 1:13
Code-o-mat15-Jun-10 1:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.