I believe I have a good understanding of what is stored on the stack(for example primitive data types) and what's stored on the heap(for example an instance of a class. But is there anyway to verify this for educational/verification of my expectations reasons?

It can be in a debugger(gdb or rad debugger or worst case vs) or directly code based(thinking something like gettype(variable) but like isstackstored(variable).

you are viewing a single comment's thread
view the rest of the comments
[–] [S] 2 points 2 months ago (2 children)

Most of those will give me a memory address but is there a way to know if that address is stack or heap?

  • source
  • parent
  • hideshow 2 child comments
  • [–] 2 points 2 months ago (1 child)

    info proc mappings should show you the memory regions mapped for stack and heap, then you can compare the address of your variable to those.

  • source
  • parent
  • hideshow 1 child comment
  • [–] [S] 2 points 2 months ago

    I don't see that in the sourceware or gnu documentation but I may be missing it (gdb is incredibly complex and documentation in long and detailed). It's 1am here so investigation into this will have to wait till tomorrow.

  • source
  • parent