Heap and Stack manipulation

Discussion in 'C' started by vsachar, Feb 19, 2009.

  1. vsachar

    vsachar New Member

    Joined:
    Feb 19, 2009
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    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.
     
  3. vsachar

    vsachar New Member

    Joined:
    Feb 19, 2009
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    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.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice