you can check the javadoc for WeakReference, but basically
WeakReferences hold the reference until a full gc occurs

On Thu, Sep 24, 2009 at 12:14 AM, Igor Vaynberg <igor.vaynb...@gmail.com> wrote:
> the instances are held in memory until the jvm runs the garbage collector.
>
> -igor
>
> On Wed, Sep 23, 2009 at 8:09 PM, Esteban Ignacio Masoero
> <emaso...@getsense.com.ar> wrote:
>> Hi:
>> I'm not sure whether this behavior is normal or not, so I'm going to
>> describe it and I hope someone can tell me if I'm doing something wrong or
>> if there's just nothing wrong!
>>
>> In my app I found out that each time a request is made, old instances of a
>> page remain in memory, and get accumulated in time (I noticed this behavior
>> by looking at the "All instances" feature from eclipse debug's perspective).
>> I searched the code for bad practices like anonyomus Model classes, but I
>> didn't find those kind of thins. So finally I created a new simple project
>> to test whether this behaviour repeated there too, and I found out that it
>> did!
>>
>> Here's the new simple project code (wicket 1.3.5, tomcat 6, eclipse
>> galileo):
>>
>> public class MyApp extends WebApplication {
>> @Override
>>  public Class getHomePage() {
>> return MyPage.class;
>> }
>> }
>>
>> public class MyPage extends WebPage {
>> private String text;
>> public MyPage() {
>>  this("<notext>");
>> }
>> public MyPage(String textt) {
>>  super();
>> this.text = textt;
>> Form form = new Form("form"){
>>  private static final long serialVersionUID = -3566834353426372805L;
>> @Override
>>  protected void onSubmit() {
>> setResponsePage(new MyPage2(text));
>> }
>>  };
>> form.add(new TextField("text", new PropertyModel(this, "text")));
>>  form.add(new Button("accept"));
>> this.add(form);
>> }
>> }
>>
>> <Class MyPage2 does the exact same thing, except it sets MyPage as the
>> response page.>
>>
>> When debugging (with a breakpoint in MyPage's constructor), every time a new
>> page is instanciated, I see that the old instances of that page remains in
>> memory. Using the "All references" feature I "walked" through the
>> reference-path, and I reached a weakReference to this page from a
>> "SerializedPagesCache$SerializedPageWithSession" instance (I had to stop
>> there because it was driving me crazy). (Of course I have no idea whether
>> this is normal or not, I'm just giving more info)
>>
>> Anyway, can anyone tell me what's wrong? Or is this a expected behavior and
>> sometime later this old instances will be eliminated from the jvm?
>>
>> Thanks in advance,
>>
>> Esteban
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>



-- 
http://mapsdev.blogspot.com/
Marcelo Takeshi Fukushima

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to