Jump to content

Memory usage tool

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
kia

kia

    Newbie

  • Members
  • PipPip
  • 24 posts
Hi!

Can anybody suggest me a tool that shows the way c++ programs allocate memory?

A sort of debugger that shows me, line by line, how the allocation of memory works...
...in order to understand memory usage,pointers,references and so on...
:).
thnx.

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Any such tool will depend heavily on the compiler and OS you are using. You can get the GCC source code, which would let you see the code for memory allocation.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
upredsun

upredsun

    Newbie

  • Members
  • Pip
  • 9 posts
you can use new operator to allocate memory.

for example:
struct mytype_t *mytype;
mytype = new mytype_t;
http://www.upredsun.com
**Easily and automatically build tcp-based or udp-based network protocol source code**

#4
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,720 posts
Memory allocation works like this:

(1) User requests a program to be run.
(2) Windows copies the executable code into memory and allocates some more memory from RAM called the heap. All memory used by said program is allocated from here. If it uses all of it up...too bad.
(3) Program decides to allocate memory for (example) a string. The appropriate allocating function is called. This function calls the heap manager that every program has. The heap manager checks the program's heap to see if there's sufficient free space. If so, it allocates the memory and returns a pointer.
(4) Program finishes playing with the string it has allocated and requests the heap manager to deallocate it. The heap manager looks up the pointer in an internal table and marks that range of memory as unused.