To help you test and improve the graphics performance of your MIDlet during development, the Symbian platform allows you to:
Graphics memory is a dedicated memory space in the device's graphics processing unit (GPU) and it is used for storing graphics resources. For more information about graphics processing on a device, see section Graphics hardware acceleration.
To perform the following monitoring activities on a MIDlet, you need a Symbian device or emulator that supports Java Runtime 2.2 for Symbian or newer.
You have two options for monitoring how much graphics memory a MIDlet consumes during runtime:
Specify the Nokia-UI-Developer-Utils
JAD attribute with
the value GPUMem
:
Nokia-UI-Developer-Utils: GPUMem
When the MIDlet is run, its graphics memory consumption is displayed on the device screen both in bytes and as a percentage of the total available memory. The displayed information includes:
The amount of free graphics memory on the device
The amount of shared memory used by the application (MIDlet) process
The amount of private memory used by the application (MIDlet) process
In the MIDlet, retrieve the value of one of the com.nokia.gpu.memory
system properties:
com.nokia.gpu.memory.total
returns the total
amount of graphics memory available on the device in bytes.
com.nokia.gpu.memory.used
returns the amount
of allocated graphics memory on the device in bytes.
com.nokia.gpu.memory.shared
returns the amount
of shared memory used by the application (MIDlet) process in bytes.
com.nokia.gpu.memory.private
returns the
amount of private memory used by the application (MIDlet) process
in bytes.
The following code snippet shows how to use the com.nokia.gpu.memory
system properties to display a MIDlet's graphics memory consumption
on the device screen.
class MyCanvas extends Canvas { // ... protected void drawGpuMem(Graphics g) { g.setFont(font); int xMargin = 5; int yMargin = getHeight() - 5; String str = System.getProperty("com.nokia.gpu.memory.private"); g.drawString("Private: " + (str != null ? str : "---"), xMargin, yMargin, Graphics.BOTTOM | Graphics.LEFT); yMargin -= fontHeight; str = System.getProperty("com.nokia.gpu.memory.shared"); g.drawString("Shared: " + (str != null ? str : "---"), xMargin, yMargin, Graphics.BOTTOM | Graphics.LEFT); yMargin -= fontHeight; str = System.getProperty("com.nokia.gpu.memory.used"); g.drawString("Used: " + (str != null ? str : "---"), xMargin, yMargin, Graphics.BOTTOM | Graphics.LEFT); yMargin -= fontHeight; str = System.getProperty("com.nokia.gpu.memory.total"); g.drawString("Total: " + (str != null ? str : "---"), xMargin, yMargin, Graphics.BOTTOM | Graphics.LEFT); } protected void paint(Graphics g) { // ... drawGpuMem(g); } }
The following figure shows a MIDlet that uses the Nokia-UI-Developer-Utils
JAD attribute to display its graphics
memory consumption (top left). The MIDlet also uses the com.nokia.gpu.memory
system properties to retrieve and display information about its
graphics memory consumption (bottom).
Figure: Graphics memory consumption displayed on the device screen
When mixing 2D and 3D graphics in a MIDlet, for example, when rendering Graphics
content over an M3G scene, you can achieve the
best performance by rendering the 2D graphics to the smallest possible
areas of the underlying Canvas
. The smaller and fewer
the Canvas
areas where you render 2D graphics, the
better the graphics performance of the MIDlet.
Java Runtime
for Symbian allows you to automatically highlight 2D graphics rendered
over 3D graphics. By studying the highlighted 2D elements, you can
determine which ones you need and which ones you can remove, and which
ones you can make smaller and by how much. To highlight 2D graphics
rendering in a MIDlet, specify the Nokia-UI-Developer-Utils
JAD attribute with
the value 2DBorders
:
Nokia-UI-Developer-Utils: 2DBorders
When the MIDlet is run, 2D graphics rendered over 3D graphics are highlighted by borders drawn around the 2D elements. The 2D elements are identified and the borders drawn based on the quadtree algorithm.
The following figure shows a MIDlet that uses
the Nokia-UI-Developer-Utils
JAD attribute to highlight
2D elements rendered over 3D content.
Figure: Highlighted 2D elements rendered over 3D content
To measure frame rate per seconds
for a MIDlet, specify the Nokia-UI-Developer-Utils
JAD attribute with
the value FrameRate
:
Nokia-UI-Developer-Utils: FrameRate
When the MIDlet is run, its frame rate per seconds is displayed on the device screen (see the preceding figures).
Here is an example JAD file of a MIDlet that uses all the above means of monitoring graphics performance:
MIDlet-1: GpuMem,,GpuMem MIDlet-Jar-Size: 6244 MIDlet-Jar-URL: GpuMem.jar MIDlet-Name: GpuMem MIDlet Suite MIDlet-Vendor: Nokia Corporation MIDlet-Version: 1.0.0 MicroEdition-Configuration: CLDC-1.1 MicroEdition-Profile: MIDP-2.1 Nokia-UI-Developer-Utils: FrameRate, GPUMem, 2DBorders