Yeah, it's quite doubtful.  The technique I would see JS engine writers
adopting would be an event generated indicating low memory (so the app can
remove cached memory).  However, this would be a far off time in the
distance, if ever & would take a while to trickle into browsers as a
standard feature.

2009/4/25 [email protected] <[email protected]>

>
> Hi Mark Renouf
> Thank you for reply.
>
> Let me try to give an example (maybe not very appropriate).
> I create tree on page. I get data for that tree from server. I can get
> data for all tree nodes to construct tree, or make new requests to
> server when user opens new nodes. Suppose whole tree is too big to
> load it all. User opens and closes nodes during his work. I can free
> memory resources connected with closed nodes (eliminate references)
> immidiately, but what if user opens it again? Then application needs
> to make new request to server. I want to avoid it. I want to let js
> engine garbage collect data only when it's not enough memory. If it
> were desktop java application I would use java.lang.ref.SoftReference.
> It is similar to regular reference to java object, it has get() method
> to get object that it holds, but that object can also be garbage
> collected when application needs memory. So I just call get() and if
> it returns null I recreated object (request it from server, read it
> from file, etc.).
> So, I was asking about something similar in GWT. Thinking about it
> again, I can see that that feature should be supported by browser's js
> gc engine, which is doubtful. Anyway, thank you for your help!
>
> On 24 апр, 19:00, Mark  Renouf <[email protected]> wrote:
> > Garbage collection in JavaScript is browser-dependent, but similar
> > rules apply as with Java. When you are no longer using the data, make
> > sure you eliminate all references to it. For example, if you've stored
> > it in an Array or Collection of some sort, be sure to null out or
> > remove those entries. The browser's JavaScript engine will do it's
> > best to garbage collect that data (some better than others
> > obviously).
> >
> > GWT goes to great lengths to do this for you as automatically as
> > possible. For example, if you perform an AJAX request for a chunk of
> > HTML and insert it into an HTML widget, insert it into the page, then
> > later remove it, GWT ensures that the element is cleanly detached from
> > the DOM and the Widget object is removed from it's parent. Assuming
> > you haven't stored it elsewhere (usually not), it will be eligable for
> > garbage collection.
> >
> > Others can probably tell you which browsers to  watch out for (IE6?),
> > and some pitfalls that might cause problems (circular references?)
> >
> > On Apr 23, 6:41 am, "[email protected]" <[email protected]> wrote:
> >
> > > I have GWT application. Use loads page, then visits links (I use GWT's
> > > Hyperlink, so page is not reloaded). Amount of data that page contain
> > > is increased (I use AJAX requests to get data from server). I have
> > > some data that shouldn't necessarily exist always, I can load it from
> > > server again. Is there any way I can tell js engine that it can be
> > > garbage collected? Something similar to java.lang.ref.SoftReference?
> >
> >
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to