Memory on remote.Request in the TIMER

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Memory on remote.Request in the TIMER

jhonny thio
hii...
I have an application that using a timer (every 1 second). The timer will always request data to the AJAX (php)..

Here is the code :

timer = new qx.client.Timer(1000);
timer.addEventListener("interval", this._timerku, this);        
timer.start();

_timerku : function()
 {
        var reqall = new qx.io.remote.Request("JtChat/thread.php", "GET", "text/plain");
        reqall.send();
        reqall.addEventListener("completed", function(e){
            .....
            .....
            .....
        }, this);
 }

It mean every second the program will make a new object (==> reqall). Does it consume a lot memory?

Maybe someone has a good step how to request AJAX every 1s ?

Thank you very much


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Memory on remote.Request in the TIMER

Alexander Back
Hi Jhonny,

jhonny thio wrote:
> hii...
> I have an application that using a timer (every 1 second). The timer will always request data to the AJAX (php)..
Just a curious question: is this really necessary for your application
or can you rely on events rather than polling the server every second?

> Here is the code :
>
> timer = new qx.client.Timer(1000);
> timer.addEventListener("interval", this._timerku, this);        
> timer.start();
>
> _timerku : function()
>  {
>         var reqall = new qx.io.remote.Request("JtChat/thread.php", "GET", "text/plain");
>         reqall.send();
>         reqall.addEventListener("completed", function(e){
>             .....
>             .....
>             .....
>         }, this);
>  }
>
> It mean every second the program will make a new object (==> reqall). Does it consume a lot memory?
Every request object is disposed after the request is completed, so in
theory there should be no increasing memory consumption. However the
garbage collection mechanism of the browsers do not release memory of
disposed objects right away. So it may lead to a increasing memory
consumption temporarily (before the cycle of the gargabe collector starts).

> Maybe someone has a good step how to request AJAX every 1s ?
Rely on events rather than polling the server could be a solution if
this is a scenario for your application.

cheers,
   Alex

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Memory on remote.Request in the TIMER

level420
Hi Alexander,

> Rely on events rather than polling the server could be a solution if
> this is a scenario for your application.
>  
I'm also thinking about a "server push" where the server initiates some
communication with the client. How would I do this without polling the
server?

The use case is to open some popup message in the client where the user
is noted about new informations. Something like "new mail available".

--
Mit freundlichen Grüßen
Dietrich Streifert
--
Visionet GmbH
Firmensitz: Am Weichselgarten 7, 91058 Erlangen
Registergericht: Handelsregister Fürth, HRB 6573
Geschäftsführer: Stefan Lindner




-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Memory on remote.Request in the TIMER

Alexander Back
In reply to this post by jhonny thio
Hi Jhonny,

please send your mails to the mailing list. This way other users also
can benefit.



jhonny thio wrote:
> Rely on events rather than polling the server could be a solution if
> this is a scenario for your application. ===> I don't understand about this step. Can you tell me how ?
I think of events on the client-side on which you can react. First of
all you should explain why you need to poll the server. Maybe it is
possible to work out other solutions.

cheers,
   Alex


> ----- Original Message ----
> From: Alexander Back <[hidden email]>
> To: qooxdoo Development <[hidden email]>
> Sent: Thursday, July 31, 2008 12:26:00 AM
> Subject: Re: [qooxdoo-devel] Memory on remote.Request in the TIMER
>
> Hi Jhonny,
>
> jhonny thio wrote:
>> hii...
>> I have an application that using a timer (every 1 second). The timer will always request data to the AJAX (php)..
> Just a curious question: is this really necessary for your application
> or can you rely on events rather than polling the server every second?
>
>> Here is the code :
>>
>> timer = new qx.client.Timer(1000);
>> timer.addEventListener("interval", this._timerku, this);        
>> timer.start();
>>
>> _timerku : function()
>>  {
>>         var reqall = new qx.io.remote.Request("JtChat/thread.php", "GET", "text/plain");
>>         reqall.send();
>>         reqall.addEventListener("completed", function(e){
>>             .....
>>             .....
>>             .....
>>         }, this);
>>  }
>>
>> It mean every second the program will make a new object (==> reqall). Does it consume a lot memory?
> Every request object is disposed after the request is completed, so in
> theory there should be no increasing memory consumption. However the
> garbage collection mechanism of the browsers do not release memory of
> disposed objects right away. So it may lead to a increasing memory
> consumption temporarily (before the cycle of the gargabe collector starts).
>
>> Maybe someone has a good step how to request AJAX every 1s ?
> Rely on events rather than polling the server could be a solution if
> this is a scenario for your application.
>
> cheers,
>    Alex

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Memory on remote.Request in the TIMER

Helder Magalhães
In reply to this post by level420


Dietrich Streifert wrote:
>
>> Rely on events rather than polling the server could be a solution if
>> this is a scenario for your application.
> I'm also thinking about a "server push" where the server initiates some
> communication with the client. How would I do this without polling the
> server?
>
Maybe you are looking for the "comet" [1] [2] concept...? There seem to be
other (similar) concepts and terms out there so crawling through articles in
ajaxian [3] may be of great use. ;-)

Hope this helps,

 Helder Magalhães

[1] http://alex.dojotoolkit.org/?p=545
[2] http://en.wikipedia.org/wiki/Comet_(programming)
[3] http://ajaxian.com/
--
View this message in context: http://www.nabble.com/Memory-on-remote.Request-in-the-TIMER-tp18736919p18750281.html
Sent from the qooxdoo-devel mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Memory on remote.Request in the TIMER

level420
Thank you Helder,

I was afraid of this answer. Is anyone running a comet like concept with an qooxdoo application?

The first use of this implementation would be to inform the client about a server outage. Something like "server is currently unreachable" popup. The qooxdoo application should get a server heartbeat which, if it stops, leads to a message.



Helder Magalhães schrieb:
Dietrich Streifert wrote:
  
Rely on events rather than polling the server could be a solution if 
this is a scenario for your application.
      
I'm also thinking about a "server push" where the server initiates some 
communication with the client. How would I do this without polling the 
server?

    
Maybe you are looking for the "comet" [1] [2] concept...? There seem to be
other (similar) concepts and terms out there so crawling through articles in
ajaxian [3] may be of great use. ;-)

Hope this helps,

 Helder Magalhães

[1] http://alex.dojotoolkit.org/?p=545
[2] http://en.wikipedia.org/wiki/Comet_(programming)
[3] http://ajaxian.com/
  

-- 
Mit freundlichen Grüßen
Dietrich Streifert
--
Visionet GmbH
Firmensitz: Am Weichselgarten 7, 91058 Erlangen
Registergericht: Handelsregister Fürth, HRB 6573
Geschäftsführer: Stefan Lindner



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Memory on remote.Request in the TIMER

jhonny thio
In reply to this post by jhonny thio
I want to make a chat application...
My scenario is the client every 1s will request to server (with AJAX).
So the client will always read the database, if there is a new message in [message table], the client will write in textarea. what do you think ?

----- Original Message ----
From: Alexander Back <[hidden email]>
To: qooxdoo Development <[hidden email]>
Sent: Thursday, July 31, 2008 1:21:29 AM
Subject: Re: [qooxdoo-devel] Memory on remote.Request in the TIMER

Hi Jhonny,

please send your mails to the mailing list. This way other users also
can benefit.



jhonny thio wrote:
> Rely on events rather than polling the server could be a solution if
> this is a scenario for your application. ===> I don't understand about this step. Can you tell me how ?
I think of events on the client-side on which you can react. First of
all you should explain why you need to poll the server. Maybe it is
possible to work out other solutions.

cheers,
  Alex


> ----- Original Message ----
> From: Alexander Back <[hidden email]>
> To: qooxdoo Development <[hidden email]>
> Sent: Thursday, July 31, 2008 12:26:00 AM
> Subject: Re: [qooxdoo-devel] Memory on remote.Request in the TIMER
>
> Hi Jhonny,
>
> jhonny thio wrote:
>> hii...
>> I have an application that using a timer (every 1 second). The timer will always request data to the AJAX (php)..
> Just a curious question: is this really necessary for your application
> or can you rely on events rather than polling the server every second?
>
>> Here is the code :
>>
>> timer = new qx.client.Timer(1000);
>> timer.addEventListener("interval", this._timerku, this);       
>> timer.start();
>>
>> _timerku : function()
>>  {
>>        var reqall = new qx.io.remote.Request("JtChat/thread.php", "GET", "text/plain");
>>        reqall.send();
>>        reqall.addEventListener("completed", function(e){
>>            .....
>>            .....
>>            .....
>>        }, this);
>>  }
>>
>> It mean every second the program will make a new object (==> reqall). Does it consume a lot memory?
> Every request object is disposed after the request is completed, so in
> theory there should be no increasing memory consumption. However the
> garbage collection mechanism of the browsers do not release memory of
> disposed objects right away. So it may lead to a increasing memory
> consumption temporarily (before the cycle of the gargabe collector starts).
>
>> Maybe someone has a good step how to request AJAX every 1s ?
> Rely on events rather than polling the server could be a solution if
> this is a scenario for your application.
>
> cheers,
>    Alex

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Memory on remote.Request in the TIMER

Siarhei Barysiuk
In reply to this post by Alexander Back
Hello,

On Thu, Jul 31, 2008 at 11:21 AM, Alexander Back
<[hidden email]> wrote:

> I think of events on the client-side on which you can react. First of
> all you should explain why you need to poll the server. Maybe it is
> possible to work out other solutions.

Some time I worked on chat application and logic how to fetch messages
from server.
It's obvious that getting messages from server every second is
unefficient way. We used
a few parameters in our algorithm to calculate interval between
requests to server.

The first parameter is user's activity. For example if the user uses
application you can
get messages from server more frequent to keep information up to date,
if the user is
inactive you use bigger interval to get messages. It's also cool to
handle if tab/open is
active but I'm afraid that it's impossible only with javascript (I
mean cross browser
solution).

The second one is count of messages from server which you got last
time. Based on
this parameter you can see activity of other people in chat and also
manage interval
between requests. It's something like google gets messages on Gmail if
server unavailable.

I'm not aware with comet very good but if I'm not wrong you need that
your server supports
this. But I don't think that its a problem.

Java developers can take a look at DWR which supports Reverse Ajax [1].

Best regards,
Siarhei Barysiuk

[1] http://directwebremoting.org/dwr/reverse-ajax

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Memory on remote.Request in the TIMER

Helder Magalhães


Siarhei Barysiuk wrote:
>
> I'm not aware with comet very good but if I'm not wrong you need that
> your server supports this.
>
Yes, this is tightly related to server support. As this is a somehow
relatively new concept, probably only a handful (didn't look for an
extensive list)  of Web servers support it - and probably through plug-ins
and/or source code patches.

Regards,

 Helder Magalhães
--
View this message in context: http://www.nabble.com/Memory-on-remote.Request-in-the-TIMER-tp18736919p18751600.html
Sent from the qooxdoo-devel mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Memory on remote.Request in the TIMER

Derrell Lipman
In reply to this post by jhonny thio
On Thu, Jul 31, 2008 at 5:27 AM, jhonny thio <[hidden email]> wrote:
I want to make a chat application...
My scenario is the client every 1s will request to server (with AJAX).
So the client will always read the database, if there is a new message in [message table], the client will write in textarea. what do you think ?

The HTTP protocol allows up to two concurrent XMLHttp requests to be active.  One option to consider if you're using a server that can retain conections is to issue an async request to the server with a long timeout.  When the server has something available for your application, it can use the pending request to send its response.  Upon receipt of that response, your application would take action based on the response and issue a new long-lived "poll" request to the server.

This still leaves the second XMLHttp request available for quick requests such as sending a message typed in your application's message area, or even "Server, are you still alive" requests.

Food for thought.

Derrell



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Memory on remote.Request in the TIMER

thron7
In reply to this post by level420
Hi Dietrch,

Dietrich Streifert wrote:
> Thank you Helder,
>
> I was afraid of this answer. Is anyone running a comet like concept
> with an qooxdoo application?

There's not much to be afraid of ;). A very simple application of this
idea is to open an async request from the client which remains
unanswered until the server has something it wants to "push" to the
client. After the push data has been received the client immediately
opens a new request which will again be pending on the server until the
next push need arises. (This is sometimes called "long polling").

The only concern here are the numbers of pending requests, both on the
server (if you have large numbers of clients) and of course on the
client that has a very limited number of concurrent connections it can
maintain. The first step is to make sure all long polling from the
client is done through a single connection so your client application
does not open multiple long polling requests simulataneously. The next
optimization is to time-out the long polling request by the server in
regular intervals when no push data is available. This allows the server
to reclaim sockets, and the client can use its connection resources for
other requests before re-opening the long polling connection. This is
sort of "interleaving" the connecion needs on the client.

You see, the basic idea is simple. But to elaborate this into a smoothly
working communication layer you start to create all kinds of
infrastructure and handling protocols (E.g if you think a moment about
managing request needs against a limited number of resources (parallel
connections in this case), you easily wind up with the idea of a request
queue and a corrsponding manager). This is all of the kind what you want
to see in a framework. I'd like to see that in qooxdoo too... :)

>
> The first use of this implementation would be to inform the client
> about a server outage. Something like "server is currently
> unreachable" popup. The qooxdoo application should get a server
> heartbeat which, if it stops, leads to a message.
>

This is actually *not* a use case for server push, but client pull. The
server usually is not able to push a message like "I'm currently
unreachable" :). This is the case for client pull where the client makes
a "ping" request in regular intervals and the server - provided it is
available - answers immediately with a tiny ACK message. This is also
easy to implement with async requests on the client (but again, a queue
would be nice here).

Thomas


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel