Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jdt-dev] Memory Management Using jdt.core.dom

Tim,

Hanging on to AST bindings can indeed lead to memory problems. General
guidelines:

For an AST created without bindings:
- an AST node is connected to its children nodes, and to its parent node
- an AST node is connected to its AST

For an AST created with bindings, the following are also true:
- the AST is connected to a set of AST bindings
- a binding is connected to the AST
- a binding is connected to one or more AST nodes
- a binding is connected to one or more other bindings

IBinding.getKey() usually returns a reasonable approximation of a form that
can be held at a "global" scope. These are Strings, so there is no residual
connection to bindings or ASTs. This problem is hard to solve in general;
there just aren't any good ways to identify things like local variable
declarations, etc.

re: mapping an IMethodBinding to a Java model IMethod handle: You should be
able to do this youself. The thing to watch out for is that IBindings are
fully resolved, whereas IMethod handles are not. E.g, a binding would say
"I am class pk.Foo's method boolean equals(java.lang.Object)" whereas class
pk.Foo might have either "I am class pk.Foo's method boolean
equals(Object)" or "I am class pk.Foo's method boolean
equals(java.lang.Object)" . You would need to account for this.

Cheers, jeem



                                                                                                                                         
                      Timothy Halloran                                                                                                   
                      <thallora@xxxxxxx         To:      jdt-dev@xxxxxxxxxxx                                                             
                      RI.CMU.EDU>               cc:                                                                                      
                      Sent by:                  Subject: [jdt-dev] Memory Management Using jdt.core.dom                                  
                      jdt-dev-admin@ecl                                                                                                  
                      ipse.org                                                                                                           
                                                                                                                                         
                                                                                                                                         
                      07/02/2002 09:23                                                                                                   
                      AM                                                                                                                 
                      Please respond to                                                                                                  
                      jdt-dev                                                                                                            
                                                                                                                                         
                                                                                                                                         



It appears that holding onto handles of ASTNodes (pretty obvious) and
the type bindings (e.g., ITypeBinding, IVariableBinding,
IPackageBinding, and IMethodBinding) (less obvious) causes the AST to
"stay" in memory -- which can lead to memory problems.  Is there some
description of "proper" use of the DOM?

Is there some method of "swizzling" type bindings into some form where
they can be held at a "global" scope without causing the ast to remain
in memory (e.g. for inter-procedure analysis)?  I have been moving them
to String oriented structures, but this seems like a hack and is really
bad for local variables (No "unique name" available, just an address).

Also is there a way to, say, transfer an IMethodBinding to an IMethod?
or an IVariableBinding (that is a field) to an IField?  (Code pointers
would be OK)

Thanks,
Tim Halloran
Carnegie Mellon University


_______________________________________________
jdt-dev mailing list
jdt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/jdt-dev






Back to the top