We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
C/C++ local vars, unless declared “static”, (typically) use stack memory or register or simply disappear at compile time.
Dynamic allocation (typically) uses heap area.
Global vars and static local vars and static member vars (typically) use a separate “static” memory area. (If you initialize them to zero and never use them, chances are OS doesn't even allocate memory for them.)
(Terminology differs from tutorial to tutorial but the idea is that there is a separate, pre-allocated part of virtual memory that is neither stack nor heap.)
See w:Data segment and cppreference:storage duration for more details.
If you have a Linux box, you can also try toying with stack limit using ulimit (assuming you are using Bash/Zsh).
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Common Child
You are viewing a single comment's thread. Return to all comments →
C/C++ local vars, unless declared “
static
”, (typically) use stack memory or register or simply disappear at compile time.Dynamic allocation (typically) uses heap area.
Global vars and static local vars and static member vars (typically) use a separate “static” memory area. (If you initialize them to zero and never use them, chances are OS doesn't even allocate memory for them.)
(Terminology differs from tutorial to tutorial but the idea is that there is a separate, pre-allocated part of virtual memory that is neither stack nor heap.)
See w:Data segment and cppreference:storage duration for more details. If you have a Linux box, you can also try toying with stack limit using
ulimit
(assuming you are using Bash/Zsh).