You are here:

C++/C++ Memory management


Hi vijayan ,

         Can you plz tell me how the memory management will happen in C++ ?. we have stack,heap , code segement and data segment .. registers etc , In a C++ programm what are the variables,functions , vtables  will store in these registers .
         Can u plz tell me know if any good site is there on these?

Many thanks in advance

Functions (code) is stored in a part of memory which is separate from that of variables (also called objects or data). On certain architectures, this area is called a code segment. For a programmer, this is largely uninteresting as the area of memory containing code can not be modified in any way at run time. All you can do is execute the code for the functions which are predetermined at the time you compile and link the code - functions can not be modified and new functions can not be created at run time.

As C++ programmers, we are interested in where our variables (objects) are stored, what is their life-time and so on. We can create objects at run time and can specify what their storage duration is. Where a variable is stored and the life time of the variable is determined my the storage duration of the variable. there are three storage durations supported by C++ : automatic, static and dynamic. Where v-tables are stored is implementation dependent, they would be in some part of the static data area.    

I had answered a like question some time back, here is the link:

For more information, you could read the next few pages starting here:  


All Answers

Answers by Expert:

Ask Experts




my primary areas of interest are generic and template metaprogramming, STL, algorithms, design patterns and c++11. i would not answer questions about gui and web programming.


about 15 years or so

post graduate engineer

©2016 All rights reserved.