In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces Flex memory optimization skills, the article is very detailed, has a certain reference value, interested friends must read it!
Flex memory optimization principle
1. All external references to the deleted object must be deleted before they can be treated as garbage collection by the system.
two。 If the child object inside the parent object is referenced by other external objects, the child object will not be deleted, and the child object will not be deleted, and the parent object will not be deleted.
3. If an external object is referenced in an object, when you are deleted or do not need to use this reference object, be sure to set the reference of this object to null
4. The reason why this object cannot be deleted is not necessarily that it has been referenced, but also that its own child is referenced externally, and the father cannot delete it because the child cannot delete it.
5. In addition to references that need to be deleted, system components or global tools or management classes that provide uninstall methods must be called to delete internal objects, otherwise memory leaks and performance losses may occur.
6. If the parent object is deleted immediately, it does not mean that the child object will be deleted or deleted immediately, and may be deleted later when it is automatically deleted by the system or when it is removed for the second time.
7. If the parent object remove the child object without clearing the reference to the child object, the child object cannot be deleted, and the parent object cannot be deleted.
8. If the registered event is not removed, it will not affect the custom forced collection mechanism, but it may affect the normal recovery mechanism, so * make sure that all registered event listeners should be removed clean.
9. The deletion of the parent object does not mean that the rest of the child objects are deleted. The leaked code in one state does not mean that there is no leakage in other states. Each module should be tested and analyzed one by one in each state until the entire object can be deleted in any state of the test.
Examples of Flex memory leaks in Flex memory optimization:
1. Reference leakage: null is required for references to sub-objects and external references to this object or sub-objects.
two。 System class leak: use the system class and forget to delete the operation, such as BindingUtils.bindSetter (), ChangeWatcher.watch () function needs to be called ChangeWatcher.unwatch () function to clear the reference, otherwise the object using this function will not be deleted
Similarly, there are MUSIC,VIDEO,IMAGE,TIMER,EVENT,BINDING and so on.
3. Effect leakage: when applying the effect Effect to the component, when the object is deleted, you need to stop the Effect animation on the object and sub-objects, and then set the target object of Effect to null;. If you do not stop the animation and directly set the Effect to null, the object will not be removed normally.
4.SWF leak: to completely delete a SWF, call its unload () method and set the object to null
5. Picture leaked: set source to null; (for testing) when the Image object is finished.
6. Audio and video leaks: when you don't need a music or video, you need to stop music, delete objects, and set null by reference.
Solution to Flex memory leak when Flex memory is optimized:
1. Garbage handling in the REMOVED_FROM_STAGE event return of the component (remove all external references (whether VO or component need to be deleted), delete listeners, call the cleanup method of the system class)
Remove before setting null to ensure that all external references of objects after remove or removeAll are released cleanly.
two。 Using Flex's performance optimization tool Profile to monitor the project process, you can know which objects have been created in history, which objects have not been deleted, the number of objects created, the proportion and amount of memory occupied, the creation process and other information.
These are all the contents of the article "what are the Flex memory optimization techniques?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.