Heap and Stack manipulation

vsachar's Avatar, Join Date: Feb 2009
Go4Expert Member
Hi all,

This is my first post here.
My team and I are creating a project where we need to access the stack segment of the application and manipulate the pointers in it. Also, we are looking for a way to specify how much heap an application can use and divide this heap into segments. We're doing this for a garbage collector for C++.

If there is any information about the above, any links or practical knowledge, we'd welcome it. We're also looking at assembly code integration with C++ but are not sure it's what we want.

Thanks in advance for any help.
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
There's almost certainly going to be a better way to do it, for instance you can write your own memory management functions and redirect new/delete/malloc/free/realloc etc to those new routines.

But in any case the stack and heap addresses can be determined simply by taking the address of variables, and of course anything you do in this area is going to be extremely dependent on the exact version of compiler and platform you're using.
0
vsachar's Avatar, Join Date: Feb 2009
Go4Expert Member
What we need is to access the stack segment of the application.

This Garbage Collector runs for an application and uses the overloaded new operator.
This collector is in c++ for WinXP environment using vc++ compiler.

Also, we need to divide the heap into user defined size. Is there any way to do that?

Thanks in advance.
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
Not without your own custom memory allocations. For example how would char *str=malloc(100) know which heap division to use? You'd need something like char *str=malloc(100,USE_DIV_3),and that doesn't exist.