Adobe Air HTML dynamic gallery - how to free memory by deleting images

I am developing a small desktop application using Adobe Air and their HTML API. The application has two windows, one of which displays a slide show of images located in a folder on the local computer, and in the other window you can view these images (one large image and previous / next buttons).

At first, for a quick test, I just downloaded all the images from the folder into the DOM of each window, and it works fine until I get too many images (150+), because they are high-resolution JPEGs from DSLR. Obviously, each image takes up a lot of memory and is likely to kill the application from overuse. So I started by optimizing the viewport, instead of loading them all, I use only one tag and replace the .src value with javascript. But this method simply delays the problems, because by continuing to browse through all the images, memory usage is growing and growing. Replacing the src image does not free the memory used by the previous image. The same thing if I try to remove the image from the DOM and recreate it.

The idea that I have, but I don’t really like, is to display the image inside the frame by loading another HTML file, passing it the src image as a parameter. Then reload the whole frame, hope it can reset to use memory. I have not tried it yet.

Anyone have an idea how to handle this?

+4
source share
1 answer

This is a good tool to optimize your Adobe Air application. Adobe Air Tuner:

I am not familiar with your project; or how it is implemented. Adobe AIR has several methods available for free memory. This will allow you to correctly delete or delete objects. These cleanings can be found here .

One thing that some people do when creating media players; especially with large carriers. Example:

Let's say your media player contains six pages of content; only 1 GB of data. This is a very, very large memory allocation for your project. So instead, immediately call the entire 1 GB; the first page loads and the second page loads.

The remaining four pages remain "unclaimed" rather than dynamically loaded. Then the user switches to the second page; page 3 starts preloading the content. The user switches to page three; page 4 starts loading. But it also has an array or objects created on the first page. Therefore, this does not affect the application.

Obviously, this method is tedious because you control all aspects of the download. It also creates problems if your user begins to quickly navigate the pages.

So, another possible solution; it would be the creation of sketches so that the size was much smaller. Then download full-size images as stand-alone streams that can be deleted without any problems once they leave this area. Thus, the gallery is independent.

If you provided some code or some additional information, I can help you above and further only for the implementation of the interface / memory.

0
source

Source: https://habr.com/ru/post/1442009/


All Articles