[Celerity-users] memory leaks and serialize blockage

jason franklin-stokes jasoninclass at googlemail.com
Thu Dec 10 15:28:22 EST 2009


Jari,

Thanks then it my fault, not celerites. I am not closing the browser after click_and_attach - so that solves that one. 
for some reason I thought that click_and_attach was sorting that out for me. 
I will put things back and see what happens. will let you know. 

BTW

Here is the code for serialize and derserialize. This breaks when the listener is enabled. 
I added the following to the Celerity::Browser class

include_class 'org.apache.commons.lang.SerializationUtils'

   def serialize_webclient
      SerializationUtils.serialize(@webclient).to_a.pack("C*")
    end

    def deserialize_webclient(_serialized_webclient)
      @webclient = SerializationUtils.deserialize(_serialized_webclient.to_java_bytes)
    end


in the cli you can the do the following. 

browser = Celerity::Browser.new
browser.goto "www.xyz.com"
browser.serialize_webclient

this will result in a java io not serializable exception 

if you make the Listner class method look like this: 

def add_listener(type, &block)
      return
end

and then run 

browser = Celerity::Browser.new
browser.goto "www.xyz.com"
browser.serialize_webclient

it will work. 

I will recheck to see if the add_listner is also responsible for memory leaks and get back to you.

jason. 




On Dec 10, 2009, at 8:39 PM, Jari Bakken wrote:

> On Thu, Dec 10, 2009 at 8:19 PM, jason franklin-stokes
> <jasoninclass at googlemail.com> wrote:
>> Jari,
>> 
>> just thinking about without looking at the code again...
>> click_and_attach is probably thowing away the old instance of the webclient while the javascipt thread is still running which means that it wont get garbage collected. closeallwindows needs to be called on the webclient instance to ensure that the javascript threads get terminated. I am just not sure what side effects that would have on the celerity code by calling close on the celerity browser instance before letting it go in click_and_attach.
>> 
>> what do you think?
>> 
> 
> Nope, click_and_attach is not throwing away any old instances. Calling
> Browser#close is the user's responsibility - Celerity can't know if
> the user still wants to use the browser. Remember, this is how
> click_and_attach is supposed to be used:
> 
>  b = Browser.new
>  b.goto("http://...)
> 
>  popup_browser = b.button(:id, 'trigger-popup-window').click_and_attach
>  popup_browser.text_field(:id, 'foo').set("foobar") # or whatever
>  popup_browser.close
> 
>  b.button(:id, 'bar').click # or whatever - continues using the same browser
> 
> If you could just show some code that exemplifies the problem you're
> having, I'm sure I'd be able to help.
> _______________________________________________
> Celerity-users mailing list
> Celerity-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/celerity-users



More information about the Celerity-users mailing list