RE: Barracuda: Re:Barracuda Memory troubles

"Mayhew, Steve" <[email protected]>
Newsgroups gmane.comp.java.enhydra.barracuda.general
Message-ID <[email protected]>
This may seem like a stupid question but... If the BComponent's are not
being kept past the request / response cycle why would they care about
changes to the model?   That is if you create a new BComponent to construct
a page it starts out invalid so you should never see the valid state in a
BComponent?

I think I'm missing something quite basic about how Barracuda is supposed to
work.  What state should be saved in the session:
 1) The models (almost certainly)
 2) The BComponent tree (seems of little value without #3)
 3) The rendered DOM tree.

Unless we are to surgically update the DOM on the browser it seems a
rendered DOM tree is either entirely valid or entirely invalid...  The only
choice is to return a complete HTML page to the client or status 304 (if
client does a conditional GET) 

Given this why have the BComponents listen to models at all?  

One approach might be to make the model's reference to listeners a
WeakReference, that way once the BComponent that references them is no
longer strongly referenced then it will be GC'd and the WeakReference will
be null'd.  Model can simply ingore (or better remove from the list) any
weakly reachable (get() returns null) BComponent objects.

Just my random thoughts.


> -----Original Message-----
> From: Vas Skrypnyk [mailto:[email protected]]
> Sent: Sunday, December 08, 2002 11:44 PM
> To: [email protected]
> Subject: RE: Barracuda: Re:Barracuda Memory troubles
> 
> 
> Hi Christian,
> 
> >Hi Bill,
> >
> >So it sounds like you release your handle to the BTemplate, 
> but the Model
> >still has a reference to it, which in turn would keep the 
> BTemplate (and any
> >components it contains) from being 
> >gc'd, since your model still has
> >references to them. Is that correct?
> 
> That's correct. 
> 
> >It almost sounds like when a component calls the 
> destroyCycle() method, it
> >needs a mechanism to disconnect any models which might 
> >be listening to that
> >component. Thoughts?
> 
> That sounds right. If destroyCycle() is called as the 
> finalization code on the BTemplate object then, since it has 
> references to all its models it should be able to disconnect 
> itself. It will still be possible to hook in the same model 
> to the same BTemplate and get the listener connection 
> replicated, but, I suppose, the programmers should take some 
> responsibility for their code :))
> 
> Cheers,
> --Bill.
> 
> >Christian
> >----------------------------------------------
> >Christian Cryder [[email protected]]
> >Internet Architect, ATMReports.com
> >Barracuda - http:
> >//barracuda.enhydra.org
> >----------------------------------------------
> >"Coffee? I could quit anytime, just not today"
> >
> >
> >> -----Original Message-----
> >> From: [email protected] [mailto:barracuda-
> >[email protected]]On
> >> Behalf Of V B Skrypnyk
> >> Sent: Saturday, December 07, 2002 10:17 PM
> >> To: [email protected]
> >> Subject: Barracuda: Re:Barracuda Memory troubles
> >>
> >>
> >> Christian,
> >>
> >> 
> >I have found where the memory leak was happening in my code. It
> >> is caused by the following scenario:
> >>
> >> 1. Create a BTemplate that will last for one servlet lifecycle
> >> (MainScreen).
> >> 2. Create 
> >a Model that represents some persistent data and store
> >> it in the session (Tabs)
> >> 3. Have different portions of your application access
> >> session-saved Model and set up their data in it. (Tabs)
> >
> >> 4. On every MainScreen instantiation add the model, so that the
> >> respective portion of the template is rendered, i.e. Tabs.
> >>
> >> What happens now is that on every addModel() call a new listener
> >
> >> is added to the model and the list keeps growing until the model
> >> drags around megabytes of listeners, as happened in my case.
> >>
> >> Now, maybe instead of appending the listeners in the List it is
> >
> >> worthwhile checking if this listener has already been added, or
> >> maybe I am misusing the Barracuda framework.
> >>
> >> Please let me know what you think.
> >>
> >> Cheers,
> >> --Bill.
> >> _______________________________________________
> >
> >> Barracuda mailing list
> >> [email protected]
> >> http://www.enhydra.org/mailman/listinfo.cgi/barracuda
> >> FAQ - http://www.jguru.com/faq/Barracuda
> >
> >_______________________________________________
> >
> >Barracuda mailing list
> >[email protected]
> >http://www.enhydra.org/mailman/listinfo.cgi/barracuda
> >FAQ - http://www.jguru.com/faq/Barracuda
> >
> _______________________________________________
> Barracuda mailing list
> [email protected]
> http://www.enhydra.org/mailman/listinfo.cgi/barracuda
> FAQ - http://www.jguru.com/faq/Barracuda
> 
_______________________________________________
Barracuda mailing list
[email protected]
http://www.enhydra.org/mailman/listinfo.cgi/barracuda
FAQ - http://www.jguru.com/faq/Barracuda
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.