# Skin destruction policy causing memory leak

**URL:** <https://forum.kirupa.com/t/skin-destruction-policy-causing-memory-leak/330333>\
**Category:** flash\
**Created:** [January 4, 2013, 6:31am UTC](https://forum.kirupa.com/t/skin-destruction-policy-causing-memory-leak/330333 "2013-01-04T06:31:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![destinier](https://avatars.discourse-cdn.com/v4/letter/d/49beb7/32.png) [@destinier](https://forum.kirupa.com/u/destinier)\
**Post date:** [January 4, 2013, 6:31am UTC](https://forum.kirupa.com/t/skin-destruction-policy-causing-memory-leak/330333/1 "2013-01-04T06:31:35Z")

</div>

In my application I am having multiple screens playing. In one screen, I have a gallery component which will play multiple videos on selection. The component is using a skin part called “vidDisplay” which is an instance of in-built class “VideoDisplay” and the skin is attached at runtime. Now when I switch back to other screen, I see that the skin is not removing its parts (ex:vidDisplay), i.e., “partRemoved” function is not calling causing “vidDisplay” continue to exist in memory, causing memory leak.

When observed the code base, I see that when a component is extending “SkinnableComponent”, mx\_internal property “skinDestructionPolicy” is set to “never” by default, which is causing memory leak in my application.

I believe that any of the following will cause “partRemoved” will be called. Please correct me if i am wrong.

1. When skinpart (ex:vidDisplay) is set to “null”
2. When skin is changed at runtime by calling attachSkin()
3. When component is removed from displayList by calling removeElement/removeChild.

Please clarify me about the scenarios where “partRemoved” will be called by the flex framework.

Last question, can we call removeChild/removeElement with skin part components? I am not sure.

Thanks in advance
