PSI and memory usage

Hi all,

Let's say I iterate over all the PsiClass of a project and process them in a specific way by exploring all the PsiElement of those classes. Keeping no reference at all to the PsiClass instances I got no problem regarding the memory usage.

But if I keep a reference for each PsiClass in a list, I got an out of memory error (using the -Xms option is not solution as I can always find a bigger project)...

Does it mean that IDEA is internally using a cache and that I should never keep any reference to Psi elements for a long time so that this mechanism can work properly?

Thanks for your help,
_marc





4 comments
Comment actions Permalink

But if I keep a reference for each PsiClass in a list, I got an out of

memory error (using the -Xms option is not solution as I can always find a
bigger project)...

I don't think this should happen when you keep only references to
PsiClass's. Don't you keep references to some other PsiElement's?

--
Valentin Kipiatkov
JetBrains, Inc
http://www.intellij.com
"Develop with pleasure!"


"Marc Polizzi" <no_mail@jetbrains.com> wrote in message
news:32279683.1070443067731.JavaMail.javamailuser@localhost...

Hi all,

>

Let's say I iterate over all the PsiClass of a project and process them in

a specific way by exploring all the PsiElement of those classes. Keeping no
reference at all to the PsiClass instances I got no problem regarding the
memory usage.
>

But if I keep a reference for each PsiClass in a list, I got an out of

memory error (using the -Xms option is not solution as I can always find a
bigger project)...
>

Does it mean that IDEA is internally using a cache and that I should never

keep any reference to Psi elements for a long time so that this mechanism
can work properly?
>

Thanks for your help,
_marc

>
>
>
>
>
>


0
Comment actions Permalink

I've switched to the version 4.0 and keep references to the qualified names of the classes and use a PsiManager.findClass() call anytime I need the PsiClass instance. No memory problem anymore? Thanks for your response.

Is there any performance issue related to the PsiManager.findClass( String, Scope ) call ?

_marc


0
Comment actions Permalink

I've switched to the version 4.0


Does it mean that you use 3.0.x version before? In this case the reason of
your members problems is clear. In 3.0.x keeping references to PsiClass'es
was memory consuming. In 4.0 you can keep references to PsiClass'es and this
should not consume too much memory.

--
Valentin Kipiatkov
JetBrains, Inc
http://www.intellij.com
"Develop with pleasure!"

"Marc Polizzi" <no_mail@jetbrains.com> wrote in message
news:24098576.1070662068181.JavaMail.javamailuser@localhost...

I've switched to the version 4.0 and keep references to the qualified

names of the classes and use a PsiManager.findClass() call anytime I need
the PsiClass instance. No memory problem anymore? Thanks for your response.
>

Is there any performance issue related to the PsiManager.findClass(

String, Scope ) call ?
>

_marc

>
>
>


0
Comment actions Permalink

Yes I was using 3.0.5. When switching to 4.0 I've changed the reference from PsiClass to their qualified names. I will rollback my changes and see what happens with the memory in 4.0.

_marc

0

Please sign in to leave a comment.