High memory usage is another concern for Scaleform application developers. AMP provides an extensive breakdown of memory consumption, as well as font and image statistics. This section demonstrates how AMP tracks memory and how it can help the developer minimize its consumption.
The file High_Memory_Use.swf under the UseCases directory simulates a high memory usage scenario. Profiling this file in AMP reveals the exact cause of the excessive memory consumption. The figure below is the memory chart and displays the memory characteristics of the example SWF file. From the chart it is evident that the MovieView and MovieData take up a significant amount of the used memory.
Figure 5: Memory maxed out
The total allocated footprint, used space, used memory, and external images, are shown in the Memory tab and can be seen in the figure below. The Memory tab also provides a high-level breakdown of the memory consumption for the selected profile frame, and organizes it by usage categories. It can be seen that MovieView memory contributes about 3.5 MB, and the MovieData memory contributes about 6 MB of the total 12 MB that is allocated. Upon further investigation of the categories within MovieView, it can be seen that most of the MovieView memory is consumed by ActionScript allocations. Indeed, there is some ActionScript code in this example file that allocates an array of 10,000 strings.
Figure 6: Memory Breakdown
In the same memory report tab we can see that most of the MovieData memory is font-related (CharDefs and Fonts categories). This raises the suspicion that glyphs are unnecessarily embedded into the SWF, and we can confirm that this is indeed the case. The Font tab, shown in figure 7, shows that there are 62,280 embedded glyphs.
Figure 7: Font tab
From the Memory tab of Figure 6, we can also see that images consume a significant amount of memory in this example. In Scaleform 4 images are not kept in RAM, and hence they do not show up as part of the Scaleform footprint. They are listed as “external images”. The list of images is available both in the Memory tab, and in the Images tab. Clicking on an image in the list results in a thumbnail preview of that image being shown in the Preview pane of AMP.
Figure 8: Image Tab and Preview