Project

General

Profile

Actions

Support #979

closed

How to output this

Added by omair geetan about 13 years ago. Updated about 13 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
-
Start date:
09/06/2011
Due date:
% Done:

0%

Estimated time:

Description

how to do the same output in Wt!

//in php

for($i=0;$i<1000000;$i) {

echo "$i Hello World ";

}

//in Wt if i do the following

for(int i=0;i<1000000;i){

root()->addWidget(new WText("Hello World"));

}

//Wt app will eat 500MB in few seconds exactly = sizeof(WText)+strlen("Hello World")*1000000 bytes!!!!

//for each request!!!!!!!, and firefox will crash before it shows anything since it will take more than 1GB

Actions #1

Updated by Wim Dumon about 13 years ago

There's many ways to do this properly.

You could use a WMessageResourceBundle:

// the 'false' parameter will not keep the resource bundle constantly in memory
wApp->messageResourceBundle().use("hello-bundle", false);

// the hello-bundle.xml contains the text corresponding to many-hellos, being a million hello worlds
// Just use one widget to display all the strings
root()->addWidget(new WText(tr("many-hellos"));

But it is usually better use WTableView (or WTreeTableView) if you need to present large amounts of data on your webpage. It supports on-demand loading, so it will send only the part that the user is actually looking at. Saves server cycles, network traffic and memory (and processing) in the browser. It's not a good idea to create millions of widgets on a single page; Wt contains enough alternatives to avoid this.

Thirdly, the real equivalent of what you do in PHP is to specialize a WResource, and in it's handleRequest() generate the 'hello world' content stream. You can write it in pieces, and you'll probably find that it will go faster and with less server memory in Wt than in PHP.

Wim.

Actions #2

Updated by omair geetan about 13 years ago

Thanx for your reply, but i was wondering why there is no Render Only widget or utility in Wt, which i can use without subclassing, just as echo or print method, and use only one instance of it.

for example

for(int i=0;i<n; i)

RenderUtil::render("some text");

Actions #3

Updated by Koen Deforche about 13 years ago

  • Status changed from New to Feedback
  • Assignee set to Koen Deforche

Hey,

Wt is a stateful framework and thus it wants to be able to rerender things at will.

Two things come closest to what you look for:

  • WViewWidget: uses a widget to render only (deleting it afterwards)
  • WResource: renders something directly to the browser. This is only intended for non-HTML output though.

Btw:

>//Wt app will eat 500MB in few seconds exactly = sizeof(WText)+strlen("Hello World")*1000000 bytes!!!!

>//for each request!!!!!!!, and firefox will crash before it shows anything since it will take more than 1GB

What would you expect that Wt can do to prevent firefox from not being able to show a page of 500MB ? Why on earth would you want to present 500MB of information to a user ?

Regards,

koen

Actions #4

Updated by omair geetan about 13 years ago

"What would you expect that Wt can do to prevent firefox from not being able to show a page of 500MB"

It is not about firefox at first place, it is about the wt internal app or server. and even if it is just 1000 row of data per session and not 1000000. wt will use memory for each session that equals to:

(sizeof(outputText)+sizeof(WText))*1000 (per session)

so if we consider 100 session at a time, wt server or app will use so much resources, just for outputting transient data.

I did port full java faces web app to c Wt framework, for memory ONLY issues. And this issue for sure contradicts Wt benefits:

"Ultra-fast load time and low bandwidth usage, which are affected only by screen complexity, not application size. Wt implements all the common tips and tricks for optimizing application responsiveness and even optimizes per browser."

Actions #5

Updated by Koen Deforche about 13 years ago

  • Status changed from Feedback to Closed

Hey Omair,

It is not about firefox at first place, it is about the wt internal app or server. and even if it is just 1000 row of data per session and not 1000000. wt will use memory for each session that equals to:

(sizeof(outputText)+sizeof(WText))*1000 (per session)

That's not the case if you use WViewWidget for example. The wt homepage uses WViewWidget for exactly this reason.

Regards,

koen

Actions

Also available in: Atom PDF