The profiler requires Flash Player version 9.0.115 or later. You can profile applications that were compiled for Flex 2, Flex 2.0.1, and Flex 3. You can use the profiler to profile ActionScript 3.0 applications that were built with Flash Authoring, as well as Adobe® AIR™ applications.
The profiler requires debugging information in the application that you are profiling. When you compile an application and launch the profiler, Flex Builder includes the debugging information in the application by default. You can explicitly include debugging information in an application by setting the debug compiler option to true. If you export an application by using the Export Release Build option, the application does not contain debugging information in it.
You can profile applications that you are currently developing in Flex Builder. Flex Builder includes debugging information when it compiles and runs an application during a profiling session. You can also profile external applications that you are not currently developing in Flex Builder but whose SWF file is available with a URL or on the file system. To profile an application, the application's SWF file must include the debugging information. For more information, see Profiling external applications.
Start profiling a Flex application
The following table describes the options:
|
Setting |
Description |
|---|---|
|
Connected From |
Shows you the server that you are launching the application from. If the application is running on the same computer as the profiler, this value is localhost. You cannot change this value. However, you can profile an application that is running on a separate computer. |
|
Application |
Shows you which application you are about to profile. You cannot change this value. |
|
Enable Memory Profiling |
Instructs the profiler to collect memory data. You use this option to detect memory leaks or find excessive object creation. If you are doing performance profiling, you can deselect this option. The default value is that the option is selected. |
|
Watch Live Memory Data |
Instructs the profiler to display memory data in the Live Objects view while profiling. This is not required for doing either memory or performance profiling. You can select this option only if you selected Enable Memory Profiling. The default value is that the option is selected. |
|
Generate Object Allocation Stack Traces |
Instructs the profiler to capture a stack trace each time a new object is created. Enabling this option can slow down the profiling experience, so you should only do it when absolutely necessary. You can select this option only if you selected Enable Memory Profiling. The default value is that the option is unselected. If you do not select this option, you cannot view allocation trace information on the Object References view or on the Allocation Trace view. |
|
Enable Performance Profiling |
Instructs the profiler to collect stack trace data at the sampling intervals. You use these samples to determine where the bulk of the execution time in your application is spent. If you are doing memory profiling, you can deselect this option. The default value is that the option is selected. |
You can change the default values of these options by changing the profiling preferences. For more information, see Setting profiler preferences.
Pause and resume profiling a Flex application
After you have started the profiler, you can pause and restart applications in the Profile view. You select an application and then select the action you want to perform on that application. The following example shows you the Profile view with multiple applications. One application is currently running, and all other applications have been terminated.
Stop profiling a Flex application
The following table describes the buttons in the profiler toolbar:
|
Button |
Name |
Description |
|---|---|---|
|
|
Resume |
Resumes the profiling session. This option is enabled only when an application name is selected and is currently suspended. |
|
|
Suspend |
Suspends the profiling session. This option is enabled only when an application name is selected and is currently running. |
|
|
Terminate |
Terminates the profiling session. This option is enabled only when an application name is selected and it has not been terminated already. |
|
|
Run Garbage Collector |
Instructs Flash Player to run garbage collection. This option is enabled only when an application name is selected and the application is currently running. For more information about garbage collection, see About garbage collection. |
|
|
Take Memory Snapshot |
Stores the memory usage of an application so that you can examine it or compare it to other snapshots. This option is enabled only when an application name is selected and that application is currently running and when you select Enable Memory Profiling in the launch dialog box. The profiler adds new memory snapshots as children of the selected application in the Profile view. To open the new memory snapshot in the Memory Snapshot view, double-click the memory snapshot entry. Garbage collection occurs implicitly before memory snapshots are recorded. In other words, clicking the Take Memory Snapshot button is the equivalent of clicking the Run Garbage Collection button and then clicking the Take Memory Snapshot button. For more information about memory snapshots, see Using the Memory Snapshot view. |
|
|
Find Loitering Objects |
Compares two memory snapshots in the Loitering Objects view. This option is enabled only when two memory snapshots are selected and when you selected Enable Memory Profiling in the launch dialog box. For more information about the Loitering Objects view, see Using the Loitering Objects view. |
|
|
View Allocation Trace |
Compares the methods between two memory snapshots in the Allocation Trace view. This option is enabled only when two memory snapshots are selected, and when you select Enable Memory Profiling in the launch dialog box. For more information about the Allocation Trace view, see Using the Allocation Trace view. |
|
|
Reset Performance Data |
Clears the performance profiling data. This option is enabled only when an application name is selected and the application is running and when you select Enable Performance Profiling in the launch dialog box. You typically click this button, interact with your application and then click the Capture Performance Profile button to get a performance snapshot of the application from the time you reset the data. For more information about the Performance Profile view, see Using the Performance Profile view. |
|
|
Capture Performance Profile |
Stores a new performance snapshot as a child of the selected application. This option is enabled only when an application name is selected and the application is running and when you select Enable Performance Profiling in the launch dialog box. To open the Performance Profile view, double-click the performance snapshot entry. For more information about the Performance Profile view, see Using the Performance Profile view. |
|
|
Delete |
Removes the selected snapshot's data from memory. Clicking this button also removes the application from the profile view, if the application has been terminated. This option is enabled only when a performance or memory snapshot is selected. |
Some views in the profiler, such as Method Statistics and Object Statistics, have navigation buttons that you use to traverse the stack or change the view. The following table describes the navigation buttons in these profiler views:
|
Button |
Name |
Description |
|---|---|---|
|
|
Back |
Shows all the methods that you traversed from the first selected method to the currently displaying method. |
|
|
Forward |
Shows the currently displayed method and the methods that lead to the currently selected method. This item is enabled after you move backward. |
|
|
Home |
Displays the first selected method. |
|
|
Open Source File |
Opens a source editor that shows the source code of the selected method. |
|
|
Filters |
Lets you control which methods you want to include in the table. For more information, see About profiler filters. |
|
|
Show/Hide Zero Time Methods |
Shows or hides methods that have a time of 0.00 in the average time column, which is a result of not showing up in any samples. |
After you run the profiler, you can save the data so that you can compare a snapshot from the current profiling session with a snapshot you take after you make changes to your code. This helps you determine if you identified the right problem areas and if your changes are improving the performance and memory usage of your application.
When you save profiling data, you save all the application data in that profile. This includes all performance profiles, memory snapshots, and allocation traces. Flex Builder writes this information to a group of binary files in the location that you specify.
You cannot delete saved application data from within Flex Builder.
You can set some profiler preferences so that your settings are applied to all profiling sessions. You can use these settings to define the Flash Player/browser that you use to profile the application in, as well as define the default filters and the port number that the application is available on, if the profiled application is running on a server.
Set Flex Builder preferences for multiple profiling sessions
Open the Preferences dialog and select Flex > Profiler.
The following example shows the profiler preferences:
Select the options under the Profiler menu to navigate to the various options. The following table describes the preferences you can set:
|
Menu Selection |
Description |
|---|---|
|
Profiler |
Lets you select the default profiling method. Select the options to enable or disable memory profiling and performance profiling. |
|
Connections |
Lets you define the port number that Flex Builder listens to the profiled application on. The default port number is 9999. You cannot change the port to 7935, because that port is used by the debugger. |
|
Exclusion Filters |
Lets you define the default packages that are excluded from the profiler views. For more information on using filters, see About profiler filters. |
|
Inclusion Filters |
Lets you defines the default packages that are included in the profiler views. All other packages are excluded. For more information on using filters, see About profiler filters. |
|
Player/Browser |
Lets you define the location of the Flash Player executable and browser executable that Flex Builder uses to run your profiled application. |
In addition to profiling applications that you are developing in Flex Builder, you can profile external applications. External applications can be SWF files located anywhere that is accessible. This includes applications that are located on a remote web server or an application that is on your local file system.
The external application must be compiled with debugging information in it before you can profile it. To compile an application with debugging information in it, add debug=true to the compiler arguments. Flex Builder also returns this error if you specify an unknown file type, such as HTML or JSP. You can only specify SWF files as external applications to profile. If the application has no debugging information, Flex Builder returns the following error:
If you get this error, recompile the application with the debug compiler option set to true and launch it again.
For the SWF file, you can specify either a URL or a file system location. If you specify a URL, Flex Builder launches the application's SWF file within the default browser. The browser must be using the debugger version of Flash Player to successfully profile the application.
If you specify a file system location for the SWF file, Flex Builder opens the application within the debugger version of the stand-alone Flash Player. In general, you should request the file by using a URL. Running applications in the stand-alone version of Flash Player can produce unexpected results, especially if your application uses remote services or network calls.
Profile an external application
You can also manually launch the application by selecting the Launch the Application Manually Outside Flex Builder option.
If you specified a SWF file that was not compiled with debugging information, Flex Builder returns an error. Recompile the application with the debug compiler option set to true and launch it again.