jeudi 19 mars 2015

C++ memory spaces


I have read through the C++ standard. However, what type of memory space are allocated and how it ties to scope and lifetime is not very clear. I will give my basic understanding but if gurus can either correct/enhance this with side rules/examples will help.


We will keep it simple to single threaded applications:



  1. Heap - dynamic memory usually using new/malloc

  2. Stack - e.g. where auto variables go

  3. Static space -- where static variables go ?

  4. Some other kinds of spaces used by the implementation NOT accessible to the program ?

  5. what other memory space is available although the C++ standard refers to an abstract machine


SCOPE: Has to do with visibility of the identifier (i.e. name/reference)


LIFETIME: Start/end time of memory allocated/de-allocated


Other related question is any algorithms / white papers to re-write malloc etc.




Aucun commentaire:

Enregistrer un commentaire