0715

Create a push behavior with a certain magnitude and angle. And look what I've got. Set the push behavior's action to be, remove this push behavior from the dynamic animator. Since its instantaneous, see how its mode is instantaneous? This is fine. I want this thing removed. I don't want it setting around there collecting dust because it's not going to fire ever again. It fired, the action method got called, I put this closure method in here to do this.

But of course this has a memory cycle, a really bad one. Because this push behavior has a var action which is a closure. So it has a strong pointer to this closure. Push behavior's action is a strong pointer to this closure. And this closure references the push behavior,  so it has a strong pointer back to the push behavior. So this will happen just fine and now the only people pointing to this push behavior, since it got removed from the dynamic animator, the only thing pointing to it is this closure. And it's pointing to closure, so they're keeping each other in the heep. So this is our classic memory cycle.

And just to remind how we break it here. We are just going to put unowned push behavior in here. Cuz we know that this can never be out of the heep when action is called by definition.

Action is only called when his push behavior does anything. So it has to clearly still be in the heep done anything .

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,900评论 0 23
  • 透明的人流激起的尘埃 舞动了一段飘逸的节奏 随后,静默一场疲惫的旅程 在雕塑的依附里 结束一场惊艳的迷途 如一场少...
    觉梦2016阅读 204评论 0 2
  • 上面是原始文本,下面是对应Markdown效果,整理出来,方便查阅. A First Level Header A...
    dreamkong阅读 292评论 0 2
  • 1.1 Android WebView 一些基本概念 开发过程中应该注意:1.AndroidManifest.xm...
    六便士少年阅读 2,051评论 2 12