• Post Reply Bookmark Topic Watch Topic
  • New Topic

Memory problem / puzzle  RSS feed

 
Bruno Dery
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I posted the topic on the JDC forums, so please follow this link to read the topic. Please answer here though for your own convenience
http://forum.java.sun.com/thread.jsp?forum=57&thread=473766
Basicly we have a swing app that has many pages (JPanels that we make visible or not depending on the user's actions). The app is like a questionnaire, and we build the gui dynamicly using data from a DB using JDO. The app starts with around 5 pages, and grows to an average of 60-70 pages, to a maximum of around 100 pages (panels), each containing an average of 200 components (other Jpanels, Jcombos, etc). The gui creation is fairly long, so we keep the pages in memory once they are packed, and only make them visible or not.
Now the puzzle is at a certain point the app runs out of memory, which is somewhere around when it takes 550 megs (using switches -XX:+AggressiveHeap or -Xms512 -Xmx512 or variants), if we minimize it it goes to around 20 megs, and when re-maximizing it it doesnt grow back to 550, but rathers stays low memory until we start displaying the pages again. What's happening behind the scenes? We would like to reproduce this behavior programmatically to avoid our memory problem. Read the post on JDC for more details, I've put some duke dollars if you want a reward for answering
Thanks in advance!!
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like the problem is that you are saving all the panels created. If each page has around 200 components and you have 60-70 pages that is 12000 - 14000 components! I might save the last 2 or 3 panels so that they can be returned to quickly, but not every panel! Nothing will ever get garbage collected so memory will just keep piling up.

I would suggest *not* saving a reference to every panel. If you need all the data entered in every panel I would make some kind of user model type class that gets filled out with data as you progress through the app. Saving this data through component references is a waste of memory because components have a lot of extra data about bounds, child components, graphics context info, etc. that you don't need.
 
Bruno Dery
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I understand your remark, and in the other forum I have posted an explanation. The short explanation is basicly speed, because the part that builds the guis take a fair ammount of time, because everything is read from the database, it is a quite complex data structure (we are using an object oriented db), and we preferred to have it all built at one step than rather building it as people go. The effect is what we wanted, the application looks faster this way, but of course is very memory hungry. So the debate between building all at once or in small chunks is pretty much over in our mins, but still, that doesnt answer my question...
 
Bruno Dery
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, like I said on the other forum, the debate over design issues is over too, I need a patch... We just can't afford to re-work it, so please read the post on JDC, and provide some answers / possible tracks to follow if you have ideas.
[ December 15, 2003: Message edited by: Bruno Dery ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!