I had a similar problem with a tree with ~100,000 nodes. I have moved to tree2. The great thing about tree2, is it operates 100% by node IDs, not nodes. Therefore, I was able to implement the flyweight pattern.

I have a tree node as a root that contains no children, but instead a reference to my root object. When asked for the children, I dynamically build children nodes for each child object, but do not store the nodes. For each of the nodes, I also do not build the children at construction, but instead when getChildren() is called, and once again do not store the children in a variable. All this is done by my object IDs. I keep a hash map of my objects (HashMap<String,MyObject> where the string is the ID), so I can easily access them.

In this way, I only have current node + number of children nodes created in the Java heap at one time.

If you go with this, just make sure you don't save the children, and make sure you implement server side node expansion.

-Andrew

On 4/18/06, Sean Schofield <[EMAIL PROTECTED]> wrote:
You are probably trying to load way too much data into the tree.  How
much data are you talking about?  I would suggest looking at the
archives for discussions on dynamic trees.  You can customize tree2
model to use a database.

Sean

On 4/17/06, Sunil Kulkarni <[EMAIL PROTECTED]> wrote:
> Hi,
>
>  I am using MyFaces 1.1.1/Tomcat 5.5.12. I am using sample TreeBacker.java
> file to render a tree.
>
>  If I don't get data from Database, then everything works fine. But, if I am
> trying to get Tree information from database and then construct 'TreeNode'
> then I get the following exception.
>
>  There is similar issue reported in users list with subject "Java heap
> space: Error with Tree2", but I did not find any answer to it.
>
>  Please let me know, if you know the solution.
>
>  Thanks.
>
>
>  javax.faces.FacesException: Caused by: javax.servlet.ServletException:
> ServletException in '/common/login_menu.jsp': Java heap space
>      at
> org.apache.jasper.runtime.PageContextImpl.doHandlePageException (PageContextImpl.java:848)
>      at
> org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
>      at
> org.apache.jsp.template.logintemplate_jsp._jspService(logintemplate_jsp.java:78)
>      at
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
>      at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>      at
> org.apache.jasper.servlet.JspServletWrapper.service (JspServletWrapper.java:322)
>      at
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
>      at
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
>      at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>      at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
>      at
> org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:173)
>      at
> org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
>      at
> org.apache.catalina.core.ApplicationDispatcher.processRequest (ApplicationDispatcher.java:463)
>      at
> org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
>      at
> org.apache.catalina.core.ApplicationDispatcher.forward (ApplicationDispatcher.java:301)
>      at
> org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:415)
>

Reply via email to