Compile the application – Apple WebObjects 3.5 User Manual

Page 157

Advertising
background image

Performance Tips

157

component’s template (the result of parsing the

.html

and

.wod

files) and

information about resources the component uses. If you cache component
definitions, the

.html

and

.wod

files are parsed only once per application rather

than once per new instance of that component. To cache component
definitions, use WOApplication’s

setCachingEnabled:

method.

public Application() {

super();
this.setCachingEnabled(true);
...

}

By default, this type of caching is disabled as a convenience for debugging.
If component-definition caching is disabled and you’re writing an entirely
scripted application, you can change code in a scripted component and see
the effects of that change without having to relaunch the application. You
should always enable component-definition caching when you deploy an
application, since performance improves significantly.

Instead of using

setCachingEnabled:

, you can also include the

-c

option on the

command line to perform component-definition caching.

WODefaultApp -c

For more information on command-line options, see the online document
Serving WebObjects.

Compile the Application

Applications written entirely in WebScript run more slowly than
applications written in a compiled language such as Java or Objective-C.
You may want to write in WebScript at first to speed the development cycle.
Then, when you’re ready to deploy, consider translating your WebScript
code into a compiled language.

Control Memory Leaks

Make sure that all objects allocated by your application are being
deallocated. OpenStep provides some tools that can help you check your
code for memory leaks. For more information, see the Debugging section
of Project Builder’s online help.

Another way to control leaks is to have the application shut down and restart
periodically, as described in the section “Automatically Terminating an
Application” (page 155).

Advertising