Hi All,

I think i am having trouble with the garbage collector deleting the memory for tree nodes that i am still using.

In my code i gather all sorts of information from FUNCTION_DECL nodes as they pass through the gimplify_function_tree() function. I gather info about types and functions and store that information in my own data sturctures. Alongside this data i also store the original tree node for the FUNCTION_DECL or type and later perform some post processing using this node to gather additional information before saving this data to a file.

I think that the garbage collector is cleaning up some of the nodes that I have stored in my structures.

How can i determine if it is deleting the memory for this node?



I have read the GCC Internals manual on garbage collection, and am not sure how I should use it in my situation. I have a dynamic array of my own structs like below:

struct TypeInfoStruct
{
  tree node;
  .... my data....
};
typedef TypeInfoStruct TypeInfo;


and i have an array of these declared in a .c file:

static TypeInfo** registered_types = NULL;

... initialise registered types array someplace in my code....


I manage the memory for the registered types array and the TypeInfo structure instances and can not give this to the garbage collector to do. However the node element in the structure seems to become invalid.

To declare the node as being a root for garbage collection and thus should not be freed should i declare my structure like:

struct TypeInfoStruct
{
  GTY(()) tree node;
  .... my data....
};


I dont think this will work from what I have read it seems the garbage collection only seems to work for single globals. How can i achieve this?

Thanks,
Brendon.

Reply via email to