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:
- Heap - dynamic memory usually using new/malloc
- Stack - e.g. where auto variables go
- Static space -- where static variables go ?
- Some other kinds of spaces used by the implementation NOT accessible to the program ?
- 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