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.
Memory usage tool
Started by kia, Jan 17 2008 03:44 PM
3 replies to this topic
#1
Posted 17 January 2008 - 03:44 PM
|
|
|
#2
Posted 18 January 2008 - 09:21 AM
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.
#3
Posted 20 January 2008 - 05:09 PM
you can use new operator to allocate memory.
for example:
struct mytype_t *mytype;
mytype = new mytype_t;
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**
**Easily and automatically build tcp-based or udp-based network protocol source code**
#4
Posted 20 January 2008 - 05:26 PM
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.
(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.


Sign In
Create Account


Back to top









