This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 216506 - opening the source for a JPA entity allocates 4GB of memory
Summary: opening the source for a JPA entity allocates 4GB of memory
Status: RESOLVED DUPLICATE of bug 216053
Alias: None
Product: javaee
Classification: Unclassified
Component: Persistence (show other bugs)
Version: 7.2
Hardware: PC Windows 7
: P1 normal (vote)
Assignee: Sergey Petrov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-08 08:05 UTC by autozoom
Modified: 2012-08-09 07:38 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
the thread dump after opening a JPA entity in the editor (207.79 KB, application/octet-stream)
2012-08-08 08:05 UTC, autozoom
Details
thread dump with 201208070001 build (115.44 KB, application/octet-stream)
2012-08-08 16:04 UTC, autozoom
Details

Note You need to log in before you can comment on or make changes to this bug.
Description autozoom 2012-08-08 08:05:03 UTC
Created attachment 122847 [details]
the thread dump after opening a JPA entity in the editor

We have a large J2EE project with hundreds of JPA entities.
When I open the source for an entity (with 8 named queries in it) Netbeans process goes from 700Mb to 4Gb of allocated memory and then stays up indefinitely.
Notice that I don't do anything in the editor, just keeping that only file open.

To achieve this I increased the heap space to 4Gb; keeping the default settings prevents me to open the file at all (Netbeans freezes and I need to kill the process).

you can find the thread dump attached

thanks
Comment 1 Sergey Petrov 2012-08-08 10:22:52 UTC
looks like a duplicate of issue 216053
but provide some hint why actions may be slow, may be because of memory consumption.
Comment 2 Sergey Petrov 2012-08-08 11:33:49 UTC
snapshot show about 2000 calls to suspected in slowness method, it may be the reason for temporary get a lot of memory as if I got it right there is no oom even with initial heap size, just gc can't be fast enouth. but also it show it's duplicate of issue 216053.can you try latest dev build and create snapshot once again?can you provide jpql query sample from you entity is you can share any?

*** This bug has been marked as a duplicate of bug 216053 ***
Comment 3 autozoom 2012-08-08 12:44:52 UTC
here is a sample of the queries:

@NamedQuery(name = "ValoreIndicatore.findMostRecentInContesto",
    query = "SELECT v FROM ValoreIndicatore AS v LEFT JOIN v.versionePerGruppo.tipo LEFT JOIN v.istanzaIndicatore.pagina.scheda.modelloValutazione.nodi as nodo "
        + "WHERE v.cartella.id=:cartellaId AND "
    + "nodo.id=:nodoId AND v.istanzaIndicatore.pagina.scheda.modelloValutazione.tipoSezione.id=3 "
    + "AND (v.versionePerGruppo.gruppo.id=:groupId OR v.versionePerGruppo.tipo.tipoVersioneSistema.id != 1) AND v.versionePerGruppo.data = "
    + "(SELECT MAX(v1.versionePerGruppo.data) FROM ValoreIndicatore as v1 LEFT JOIN v1.versionePerGruppo.tipo left join v1.istanzaIndicatore.pagina.scheda.modelloValutazione.nodi as nodo "
        + "WHERE v1.cartella.id=:cartellaId "
    + "AND nodo.id=:nodoId AND v1.istanzaIndicatore.pagina.scheda.modelloValutazione.tipoSezione.id=3 "
    + "AND (v1.versionePerGruppo.gruppo.id=:groupId OR v1.versionePerGruppo.tipo.tipoVersioneSistema.id != 1))"),
    @NamedQuery(name = "ValoreIndicatore.findByModello",
    query = "SELECT v FROM ValoreIndicatore AS v WHERE v.istanzaIndicatore.pagina.scheda.modelloValutazione.id = :modValId "
    + "AND v.versionePerGruppo.id IN (:versionIds)"),
    @NamedQuery(name = "ValoreIndicatore.findByVersion",
    query = "SELECT v FROM ValoreIndicatore AS v WHERE v.versionePerGruppo.id = :versionId")


I am downloading the nightly build, will post the new thread dump asap
Comment 4 Sergey Petrov 2012-08-08 13:30:49 UTC
can you provide a hint how this v1.istanzaIndicatore.pagina.scheda.modelloValutazione.tipoSezione.id may be constructed, if v1 is some entity, what is istanzaIndicatore.pagina.scheda.modelloValutazione.tipoSezione.id? it may help to determine this case and skip some long action for this.
Comment 5 autozoom 2012-08-08 15:18:18 UTC
it's a chain of @ManyToOne relationships between entities

ValoreIndicatoreBase.java:
...
@ManyToOne
    @JoinColumn(name = "ID_TBL_ISTANZA_INDICATORE", referencedColumnName = "ID", nullable = true)
    public IstanzaIndicatore getIstanzaIndicatore() {
        return istanzaIndicatore;
    }
...

IstanzaIndicatore.java:
...
@ManyToOne
    @JoinColumn(name = "ID_pagina", referencedColumnName = "IDPAGINA", nullable = true)
    public Pagina getPagina() {
        return pagina;
    }
...

and so on
Comment 6 autozoom 2012-08-08 16:04:09 UTC
Created attachment 122881 [details]
thread dump with 201208070001 build
Comment 7 autozoom 2012-08-08 16:07:01 UTC
I tried the 201208070001 build (find the dump attached).
It behaves better, byt memory still goes up to 1.9Gb by only opening the entity source code (memory then stays steady at 1.9).
Editor becomes less responsive, and autocomplete for named queries needs a very long time to show its suggestions.
Comment 8 Sergey Petrov 2012-08-08 16:12:38 UTC
thanks, I see calls to Elements.getTypeElement drop from 2000 to 250 in this build, is it with the same entity? Also as I got it's not enough so far.
Comment 9 autozoom 2012-08-09 07:38:22 UTC
yes it's the same entity as before